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

add merge ROIs feature #9

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/roi/createRoi.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,29 @@

mask = createRoiLabel(mask);

case 'merge'

roiImages = specification;
Copy link
Contributor

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. :-)

Copy link
Collaborator Author

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')};

Copy link
Contributor

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');


mask = [];

% loop through the ROIs to merge
for iRoi = 1:length(roiImages)

% load one ROI per time
maskToMerge = spm_read_vols(spm_vol(roiImages{iRoi}));

mask = cat(4, mask, maskToMerge);

end

% merge the logical masks into one
mask = any(mask, 4);

% assign fileprefix (name to be save?)
% [ WIP ]
% mask = createRoiLabel(mask);

case 'expand'

% Ugly hack
Expand Down