Attachment 'marsbarbatchconvert.m'
Download 1 % J Grahn
2 % MarsBaR batch script to convert roi format to image format
3 %% See http://marsbar.sourceforge.net
4 %
5 roi_dir = '/imaging/jessica/anatomy toolboxes/rois/MNItemplateROIs'; %Directory with ROIs to convert
6
7 % MarsBaR version check
8 if isempty(which('marsbar'))
9 error('Need MarsBaR on the path');
10 end
11 v = str2num(marsbar('ver'));
12 if v < 0.35
13 error('Batch script only works for MarsBaR >= 0.35');
14 end
15 marsbar('on'); % needed to set paths etc
16
17 % %For a single, named ROI
18 % roi_name = fullfile(roi_dir, 'MNI_Putamen_L_roi.mat');
19 % roi_array{1} = maroi(roi_name);
20 %
21 % for roi_no = 1:length(roi_array)
22 % roi = roi_array{roi_no};
23 % save_as_image(roi, fullfile(roi_dir, 'test.nii'))
24 % end
25
26 %For batch converting the contents of a directory of ROIs
27 roi_namearray = dir(fullfile(roi_dir, '*_roi.mat'))
28 for roi_no = 1:length(roi_namearray)
29 roi_array{roi_no} = maroi(fullfile(roi_dir, roi_namearray(roi_no).name));
30 roi = roi_array{roi_no};
31 name = strtok(roi_namearray(roi_no).name, '.')
32 save_as_image(roi, fullfile(roi_dir, [name '.nii']))
33 end
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.