Attachment 'marsbarbatch.m'
Download 1 % MarsBaR batch script to make ROIs
2 % See http://marsbar.sourceforge.net
3 %Adapted by J Grahn
4
5 root_dir = '/imaging/jessica/Beat/';
6
7 % Directory to store (and load) ROI files
8 roi_dir = fullfile(root_dir, 'RFX/ROIs');
9
10 % MarsBaR version check
11 if isempty(which('marsbar'))
12 error('Need MarsBaR on the path');
13 end
14 v = str2num(marsbar('ver'));
15 if v < 0.35
16 error('Batch script only works for MarsBaR >= 0.35');
17 end
18 marsbar('on'); % needed to set paths etc
19
20 % Set up the SPM defaults, just in case
21 spm('defaults', 'fmri');
22 %Optional: this is a list of coordinates from which Marsbar will make
23 %sphere ROIs. You can specify details of each ROI separately instead of
24 %using a list like this (look at commented out script below the for:end
25 %loop.
26 sphere_centres = {[-6;6;54]
27 [6;3;63]
28 [6;15;48]
29 [-45;-3;45]
30 [-42;3;27]
31 [-39;-24;51]
32 [-48;-42;21]
33 [48;6;24]
34 [54;0;45]
35 [54;12;15]
36 [66;-36;15]
37 [66;-24;3]
38 [51;-24;3]
39 [30;24;0]
40 [30;-57;-27]
41 [42;-66;-27]
42 [42;-39;45]
43 [36;-45;45]
44 [-24;-69;-51]
45 [-27;-60;-27]
46 [33;-87;-6]
47 [24;-90;-6]
48 [-24;-93;-3]
49 [24;-66;-51]
50 [33;-60;-51]
51 [39;36;27]
52 [18;6;-3]
53 [-54;-21;3]
54 [-6;-18;-3]
55 [-36;30;21]
56 [-36;-60;-9]}
57 %Make sphere ROIs from list given above.
58 for x = 1:size(sphere_centres)
59 area =['roi' ]
60 sphere_centre = sphere_centres{x}'
61 sphere_radius = 5
62 sphere_roi = maroi_sphere(struct('centre', sphere_centre, 'radius', sphere_radius));
63 % Give it a name
64 details = [area int2str(sphere_centre) int2str(sphere_radius)]
65 details = details(details ~= ' ')
66 roitosave = label(sphere_roi, details)
67 % save ROI to MarsBaR ROI file, in current directory
68 detailsmat = [details, '_roi.mat']
69 saveroi(roitosave, fullfile(roi_dir,detailsmat ));
70 % also Save as image that can be viewed in MRIcroN
71 detailsimg = [details, '_roi.nii']
72 save_as_image(roitosave, detailsimg);
73 end
74 %*********************************************
75 %if instead you need to make a bunch of different types of ROIs, comment
76 %out the entire for end loop above, and use this part of the script instead.
77 %%See maroi_box and maroi_img (in marsbar directory) for other types of ROIs
78
79
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 %%THIS SECTION NAMES ROIS AS THEIR COORDINATES AND RADII
82
83 % %Make sphere ROI
84 % area = 'SMA_10sph'
85 % sphere_centre = [-8 2 72];
86 % sphere_radius = 10
87 % sphere_roi = maroi_sphere(struct('centre', sphere_centre, 'radius', sphere_radius));
88 % % Give it a name
89 % details = [area int2str(sphere_centre) int2str(sphere_radius)]
90 % details = details(details ~= ' ')
91 % roitosave = label(sphere_roi, details)
92 % % save ROI to MarsBaR ROI file, in current directory, just to show how
93 % detailsmat = [details, '_roi.mat']
94 % saveroi(roitosave, fullfile(roi_dir,detailsmat ));
95 % % Save as image
96 % detailsimg = [details, '_roi.nii']
97 % save_as_image(roitosave, detailsimg);
98 %
99 %
100 % %Make sphere ROI
101 % area = 'LIFG_5sph'
102 % sphere_centre = [-52 13 14];
103 % sphere_radius = 5
104 % sphere_roi = maroi_sphere(struct('centre', sphere_centre, 'radius', sphere_radius));
105 % % Give it a name
106 % details = [area int2str(sphere_centre) int2str(sphere_radius)]
107 % details = details(details ~= ' ')
108 % roitosave = label(sphere_roi, details)
109 % % save ROI to MarsBaR ROI file, in current directory, just to show how
110 % detailsmat = [details, '_roi.mat']
111 % saveroi(roitosave, fullfile(roi_dir,detailsmat ));
112 % % Save as image
113 % detailsimg = [details, '_roi.nii']
114 % save_as_image(roitosave, detailsimg);
115
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 % %THIS SECTION NAMES ROIS BY HAND, AND STORES THEM SO THEY CAN BE COMBINED
118 %
119 % %Make sphere ROI
120 % sphere_centre = [-6 -4 66];
121 % sphere_radius = 4
122 % sphere_roi = maroi_sphere(struct('centre', sphere_centre, 'radius', sphere_radius));;
123 % % Give it a name
124 % roitosave = label(sphere_roi, 'LSMAsphere_4mm_highres_-6_-4_66')
125 % LSMAroi = roitosave
126 % % save ROI to MarsBaR ROI file, in current directory, just to show how
127 % saveroi(roitosave, fullfile(roi_dir, 'LSMAsphere_4mm_highres_-6_-4_66_roi.mat'));
128 %
129 % % Save as image
130 % save_as_image(roitosave, 'LSMAsphere_4mm_highres_-6_-4_66_roi.nii');
131 %
132 % %Make sphere ROI
133 % sphere_centre = [6 0 66];
134 % sphere_radius = 4
135 % sphere_roi = maroi_sphere(struct('centre', sphere_centre, 'radius', sphere_radius));;
136 % % Give it a name
137 % roitosave = label(sphere_roi, 'RSMAsphere_4mm_highres_6_0_66')
138 % RSMAroi = roitosave
139 % % save ROI to MarsBaR ROI file, in current directory, just to show how
140 % saveroi(roitosave, fullfile(roi_dir, 'RSMAsphere_4mm_highres_6_0_66_roi.mat'));
141 %
142 % % Save as image
143 % save_as_image(roitosave, 'RSMAsphere_4mm_highres_6_0_66_roi.nii');
144
145 %THIS COMBINES ALL NAMED ROIS SPECIFIED ABOVE INTO 1 BIG ROI
146
147 % All_rois = RSMAroi + LSMAroi;
148 % % Give it a name
149 % All_rois = label(All_rois, 'RSMA+LSMA_4mmhighres_roi');
150 %
151 % % save ROI to MarsBaR ROI file, in current directory
152 % saveroi(All_rois, fullfile(roi_dir, 'RLSMA_4mmhighres_roi.mat'));
153 %
154 % % Save as image
155 % save_as_image(All_rois, RLSMA_4mmhighres_roi.nii');
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.