From 5d44288aef53fa74ad719fb982ef04fa70981f80 Mon Sep 17 00:00:00 2001 From: Mengxing Liu Date: Thu, 13 Feb 2020 17:50:30 -0800 Subject: [PATCH 1/2] using exsiting native ROIs instead of converting it in AFQ --- functions/AFQ_Create.m | 4 +- functions/AFQ_SegmentFiberGroups.m | 71 +++++++++++++++++------------- tmux-client-3598.log | 2 + 3 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 tmux-client-3598.log diff --git a/functions/AFQ_Create.m b/functions/AFQ_Create.m index 7355ea2..ff9029d 100644 --- a/functions/AFQ_Create.m +++ b/functions/AFQ_Create.m @@ -334,8 +334,8 @@ % For some reason it is not going inside this loop, at least when testing in black the docker container -% if AFQ_get(afq,'use mrtrix') - if true +%if AFQ_get(afq,'use mrtrix') +if true disp('use mrtrix is true') for ii = 1:AFQ_get(afq,'num subs') mrtrixdir = fullfile(afq.sub_dirs{ii},'mrtrix'); diff --git a/functions/AFQ_SegmentFiberGroups.m b/functions/AFQ_SegmentFiberGroups.m index f3990b2..b94b206 100644 --- a/functions/AFQ_SegmentFiberGroups.m +++ b/functions/AFQ_SegmentFiberGroups.m @@ -324,41 +324,52 @@ fgCopy=fg; fgCopy.subgroup=[]; for roiID=1:size(moriRois, 1) % Load the nifit image containing ROI-1 in MNI space - ROI_img_file=fullfile(tdir, 'MNI_JHU_tracts_ROIs', [moriRois{roiID, 1}]); + moridir = '/share/wandell/users/glerma/TESTDATA/FS/17_CAMINO_6835_2/pipeline/input' + ROI_img_file=fullfile(moridir, 'MORI', ['MORI_' moriRois{roiID, 1}]); % Transform ROI-1 to an individuals native space - if recomputeROIs - % Default is to use the spm normalization unless a superior - % ANTS normalization was passed in - if exist('antsInvWarp','var') && ~isempty(antsInvWarp) - outfile = fullfile(fileparts(dt6File),'ROIs',moriRois{roiID, 1}); - roi1(roiID) = ANTS_CreateRoiFromMniNifti(ROI_img_file, antsInvWarp, [], outfile); - else - [RoiFileName, invDef, roi1(roiID)]=dtiCreateRoiFromMniNifti(dt6File, ROI_img_file, invDef, true); - end - else - RoiFileName=fullfile(fileparts(dt6File), 'ROIs', [prefix(prefix(ROI_img_file, 'short'), 'short') '.mat']); - roi1(roiID) = dtiReadRoi(RoiFileName); - end +% if recomputeROIs +% % Default is to use the spm normalization unless a superior +% % ANTS normalization was passed in +% if exist('antsInvWarp','var') && ~isempty(antsInvWarp) +% outfile = fullfile(fileparts(dt6File),'ROIs',moriRois{roiID, 1}); +% roi1(roiID) = ANTS_CreateRoiFromMniNifti(ROI_img_file, antsInvWarp, [], outfile); +% else +% [RoiFileName, invDef, roi1(roiID)]=dtiCreateRoiFromMniNifti(dt6File, ROI_img_file, invDef, true); +% end +% else +% RoiFileName=fullfile(fileparts(dt6File), 'ROIs', [prefix(prefix(ROI_img_file, 'short'), 'short') '.mat']); +% roi1(roiID) = dtiReadRoi(RoiFileName); + RoiFileName=fullfile(fileparts(dt6File), 'ROIs', [prefix(prefix(moriRois{roiID, 1}, 'short'), 'short') '.mat']); + roi1(roiID) = dtiImportRoiFromNifti(ROI_img_file); + if ~exist(fullfile(fileparts(dt6File), 'ROIs'), 'dir') + mkdir(fullfile(fileparts(dt6File), 'ROIs')) + end + dtiWriteRoi(roi1(roiID), RoiFileName) +% end % Find fibers that intersect the ROI [fgOut,contentiousFibers, keep1(:, roiID)] = dtiIntersectFibersWithRoi([], 'and', minDist, roi1(roiID), fg); keepID1=find(keep1(:, roiID)); % Load the nifit image containing ROI-2 in MNI space - ROI_img_file=fullfile(tdir, 'MNI_JHU_tracts_ROIs', [moriRois{roiID, 2}]); - % Transform ROI-2 to an individuals native space - if recomputeROIs - [RoiFileName, invDef, roi]=dtiCreateRoiFromMniNifti(dt6File, ROI_img_file, invDef, true); - % Default is to use the spm normalization unless a superior - % ANTS normalization was passed in - if exist('antsInvWarp','var') && ~isempty(antsInvWarp) - outfile = fullfile(fileparts(dt6File),'ROIs',moriRois{roiID, 2}); - roi2(roiID) = ANTS_CreateRoiFromMniNifti(ROI_img_file, antsInvWarp, [], outfile); - else - [RoiFileName, invDef, roi2(roiID)]=dtiCreateRoiFromMniNifti(dt6File, ROI_img_file, invDef, true); - end - else - RoiFileName=fullfile(fileparts(dt6File), 'ROIs', [prefix(prefix(ROI_img_file, 'short'), 'short') '.mat']); - roi2(roiID) = dtiReadRoi(RoiFileName); - end + ROI_img_file=fullfile(moridir, 'MORI', ['MORI_', moriRois{roiID, 2}]); + +% % Transform ROI-2 to an individuals native space +% if recomputeROIs +% [RoiFileName, invDef, roi]=dtiCreateRoiFromMniNifti(dt6File, ROI_img_file, invDef, true); +% % Default is to use the spm normalization unless a superior +% % ANTS normalization was passed in +% if exist('antsInvWarp','var') && ~isempty(antsInvWarp) +% outfile = fullfile(fileparts(dt6File),'ROIs',moriRois{roiID, 2}); +% roi2(roiID) = ANTS_CreateRoiFromMniNifti(ROI_img_file, antsInvWarp, [], outfile); +% else +% [RoiFileName, invDef, roi2(roiID)]=dtiCreateRoiFromMniNifti(dt6File, ROI_img_file, invDef, true); +% end +% else +% RoiFileName=fullfile(fileparts(dt6File), 'ROIs', [prefix(prefix(ROI_img_file, 'short'), 'short') '.mat']); +% roi2(roiID) = dtiReadRoi(RoiFileName); + roi2(roiID) = dtiImportRoiFromNifti(ROI_img_file); + RoiFileName=fullfile(fileparts(dt6File), 'ROIs', [prefix(prefix(moriRois{roiID, 2}, 'short'), 'short') '.mat']); + dtiWriteRoi(roi1(roiID), RoiFileName) +% end %To speed up the function, we intersect with the second ROI not all the %fibers, but only those that passed first ROI. fgCopy.fibers=fg.fibers(keepID1(keepID1>0)); diff --git a/tmux-client-3598.log b/tmux-client-3598.log new file mode 100644 index 0000000..e6b4716 --- /dev/null +++ b/tmux-client-3598.log @@ -0,0 +1,2 @@ +1581552296.322535 got 211 from server +1581552296.322600 got 203 from server From 0a48fda51c0769247b2d1021eebb0afded44961d Mon Sep 17 00:00:00 2001 From: Mengxing Liu Date: Thu, 13 Feb 2020 19:58:57 -0800 Subject: [PATCH 2/2] using existing ROI instead of convert in AFQ --- functions/AFQ_SegmentFiberGroups.m | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/AFQ_SegmentFiberGroups.m b/functions/AFQ_SegmentFiberGroups.m index b94b206..2492cb3 100644 --- a/functions/AFQ_SegmentFiberGroups.m +++ b/functions/AFQ_SegmentFiberGroups.m @@ -324,6 +324,7 @@ fgCopy=fg; fgCopy.subgroup=[]; for roiID=1:size(moriRois, 1) % Load the nifit image containing ROI-1 in MNI space + %% LMX: need to fix this hard code path for native space ROI moridir = '/share/wandell/users/glerma/TESTDATA/FS/17_CAMINO_6835_2/pipeline/input' ROI_img_file=fullfile(moridir, 'MORI', ['MORI_' moriRois{roiID, 1}]); % Transform ROI-1 to an individuals native space