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 using existing native space ROIs instead of converting it in AFQ #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions functions/AFQ_Create.m
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
72 changes: 42 additions & 30 deletions functions/AFQ_SegmentFiberGroups.m
Original file line number Diff line number Diff line change
Expand Up @@ -324,41 +324,53 @@
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}]);
%% 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
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));
Expand Down
2 changes: 2 additions & 0 deletions tmux-client-3598.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1581552296.322535 got 211 from server
1581552296.322600 got 203 from server