Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creation of empty mask #15

Merged
merged 4 commits into from
Feb 16, 2023
Merged

Conversation

valosekj
Copy link
Member

This PR adds a feature that creates an empty mask if segmentation does not exist. This is useful, for example, when creating MS lesion segmentations from scratch.

Please, could you double-check especially the part of the code responsible for empty mask creation:

manual-correction/utils.py

Lines 254 to 264 in bba77ad

def create_empty_mask(fname, fname_label):
"""
Create empty mask from reference image
:param fname: path to reference image
:param fname_label: path to output mask under derivatives
"""
img = nib.load(fname)
data = np.zeros(img.shape)
img_mask = nib.Nifti1Image(data, img.affine, img.header)
nib.save(img_mask, fname_label)
print("Empty mask created: {}".format(fname_label))

Fixes #4

Copy link
Member

@sandrinebedard sandrinebedard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to add the added requirements, the rest works well!

I tested for FILES_LESION and FILES_LABEL and works perfectly.

utils.py Show resolved Hide resolved
utils.py Show resolved Hide resolved
Copy link
Contributor

@naga-karthik naga-karthik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions, rest looks good!

utils.py Outdated Show resolved Hide resolved
utils.py Outdated Show resolved Hide resolved
utils.py Outdated Show resolved Hide resolved
- clarify docstring
- clarify nib.Nifti1Image command
- improve print to CLI
@valosekj
Copy link
Member Author

Thank you for reviewing! I addressed your comments. --> merging

@valosekj valosekj merged commit 6d364c9 into main Feb 16, 2023
@valosekj valosekj deleted the jv/4-allow_to_create_empty_mask branch February 16, 2023 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

manual_correction.py - allow to create MS lesion from scratch
3 participants