Skip to content

[ENH] improve roi plotting #46

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

Merged
merged 3 commits into from
Jun 5, 2022
Merged
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
6 changes: 5 additions & 1 deletion src/roi/plotDataInRoi.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ function labelAxis(roiAs, rows, cols, subplotList, roiImages, dataLabel)
subplot(rows, cols, subplotList(1, i));

bf = bids.File(roiImages{i});
title(sprintf('roi: %s', bf.entities.label));
desc = '';
if isfield(bf.entities, 'desc')
desc = sprintf('- desc: %s', bf.entities.desc);
end
title(sprintf('roi: %s%s', bf.entities.label, desc));

subplot(rows, cols, subplotList(end, i));

Expand Down
33 changes: 28 additions & 5 deletions src/roi/resliceRoiImages.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
% (C) Copyright 2021 CPP ROI developers

function reslicedImages = resliceRoiImages(referenceImage, imagesToCheck)
function [reslicedImages, matlabbatch] = resliceRoiImages(referenceImage, imagesToCheck, dryRun)
%
% Check if images are in the same orientation and reslice if necessarrry.
%
% USAGE::
%
% reslicedImages = resliceRoiImages(referenceImage, imagesToCheck, dryRun)
%
% :param referenceImage:
% :type referenceImage: path
%
% :param imagesToCheck:
% :type imagesToCheck: path or cellstr
%
% :param dryRun: Returns the matlabbatch without running it.
% :type dryRun: logical
%
% (C) Copyright 2021 CPP ROI developers

% TODO
% - allow option to binarize output?

if nargin < 3
dryRun = false;
end

matlabbatch = {};

% check if files are in the same space
% if not we reslice the ROI to have the same resolution as the data image
sts = checkRoiOrientation(referenceImage, imagesToCheck);
Expand All @@ -13,9 +34,11 @@

else

matlabbatch = {};
matlabbatch = setBatchReslice(matlabbatch, referenceImage, imagesToCheck);
spm_jobman('run', matlabbatch);

if ~dryRun
spm_jobman('run', matlabbatch);
end

basename = spm_file(imagesToCheck, 'basename');
reslicedImages = spm_file(imagesToCheck, 'basename', ...
Expand Down