attachment:marsbarbatchconvert.m of MarsBar - MRC CBU Imaging Wiki
location: attachment:marsbarbatchconvert.m of MarsBar

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.
  • [get | view] (2009-07-14 13:53:34, 4.8 KB) [[attachment:marsbarbatch.m]]
  • [get | view] (2009-07-14 13:58:18, 1.0 KB) [[attachment:marsbarbatchconvert.m]]
  • [get | view] (2009-07-14 13:58:03, 3.3 KB) [[attachment:marsbarbatchextract.m]]
  • [get | view] (2013-02-04 15:00:28, 3.2 KB) [[attachment:mrclogo.gif]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.