-
Notifications
You must be signed in to change notification settings - Fork 6
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
add merge ROIs feature #9
base: main
Are you sure you want to change the base?
Conversation
I would try
My 2 cents: load all images as a "4D" image and use images = {filenameA; filenameB};
mask = spm_read_vols(spm_vol(images));
mask = any(mask, 4); This will give a logical So assuming that you gave binary masks as inputs this should be fine. Further assumptions we have here are the images have the same dimensions. I think we can make this more flexible by making some sort of recusive call to |
@@ -146,6 +146,33 @@ | |||
|
|||
mask = createRoiLabel(mask); | |||
|
|||
case 'merge' | |||
|
|||
roiImages = specification; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still developping this but I suspect we'll want to have the same way to use specification for all "cases":
so that it will be something like :
specification(1).mask = roi_filenameA
specification(2).mask = roi_filenameB
not necessary to have now but just to let you know that the "API" and the type and name of arguments for this function are still a moving target. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this replys to it but in a batch file you would have eg
roiImages = {fullfile(opt.ROI.roiDir, 'label-sphere5xMinus40yMinus50zMinus22_mask.nii'); ...
fullfile(opt.ROI.roiDir, 'label-sphere5x36yMinus46zMinus17_mask.nii')};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More like this
specification(1).mask = fullfile(opt.ROI.roiDir, 'label-sphere5xMinus40yMinus50zMinus22_mask.nii');
specification(2).mask = fullfile(opt.ROI.roiDir, 'label-sphere5x36yMinus46zMinus17_mask.nii');
src/roi/createRoi.m
Outdated
end | ||
|
||
% check that there are no >1s | ||
mask.img(mask.img > 1) = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure that in this case you can just convert mask.img to a logical array:
mask.img = logical(mask.img);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that using
% merge the logical masks into one
mask = any(mask, 4);
will save us from having values >1
although, maybe for the future, we would like to have different values for each single single ROI merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean having a single image that combines different masks has a different "label" for each ROI: I agree but I would have that as an entirely different function.
And I think that MarsBar must have some functions to do that.
Thanks Remi :)
I am not sure that
ok great!
Yes indeed, would you add a check for that?
|
last but not least, what about the name? Tricky one if we don't want to end up with a very long one eg:
|
also (this one can become an issue by itself), do you think it would be possible to have a more human-readable label like
instead of
this way we can have a nicer name for the merged masks like
|
I mean I think that last one rolls off the tongue quite easily... |
I think that if you sue |
I would use the roiImage = `label-sphere5xMinus40yMinus50zMinus22_mask.nii`;
roiImage = renameFile(roiImage, ...
struct('label', 'sphere 5 left MT', ...
'hs', 'lh')); See the |
Yes, I "grew up" using I'm adding @mohmdrezk here in case he has a preference for nifti toolbox some reason that I do not know! |
Open questions:
load_nii()
is not happy with masks that, I guess, are not resliced in MNI space cause of distortions in the image. Solution? Seems thatload_untouch.nii()
ignores these distortions but not 100% sure about what it does.how naming the resulting
*mask.nii
from 2 or more masks? @Remi-Gausum more than 1 matrix in an elegant way (no
for loop
)