Christoph Budziszewski commited on 2009-02-06 11:51:00
Zeige 5 geänderte Dateien mit 100 Einfügungen und 77 Löschungen.
... | ... |
@@ -42,7 +42,6 @@ imageFiles = getImageFileList(des,~smoothed); |
42 | 42 |
|
43 | 43 |
|
44 | 44 |
extr = calculateImageData(imageFiles,voxelList); |
45 |
-rawdata = extr.dat; |
|
46 | 45 |
|
47 | 46 |
nVoxel = size(voxelList,1); |
48 | 47 |
|
... | ... |
@@ -52,7 +51,12 @@ calculatePstOpts.eventList = eventList; |
52 | 51 |
calculatePstOpts.sessionList = sessionList; |
53 | 52 |
|
54 | 53 |
for iVoxel = 1:nVoxel |
55 |
- pst{nVoxel} = calculatePST(timeline,calculatePstOpts,rawdata(iVoxel)); |
|
54 |
+ rawdata = []; |
|
55 |
+ for iImage = 1:length(extr); |
|
56 |
+ tmp = extr(iImage); |
|
57 |
+ rawdata = [rawdata tmp.dat(iVoxel)]; |
|
58 |
+ end |
|
59 |
+ pst{iVoxel} = calculatePST(timeline,calculatePstOpts,rawdata); |
|
56 | 60 |
end |
57 | 61 |
|
58 | 62 |
% for voxel = 1:size(voxelList,1) % [[x;x],[y;y],[z;z]] |
... | ... |
@@ -1,24 +1,52 @@ |
1 |
-% filenameList (e.g. as in SPM.xY.VY) |
|
2 |
-% voxelList in [x y z], 1 coordinate per row, untransformed |
|
1 |
+% filenameList as in SPM.xY.VY |
|
2 |
+% voxelList in [x y z], 1 coordinate per row |
|
3 | 3 |
|
4 |
-function extr = calculateImageData(filenameList, voxelList, imageOpts) |
|
5 |
-TRANSFORM_METHOD = 'image'; |
|
4 |
+function extr = calculateImageData(filenameList, voxelList) |
|
5 |
+TRANSFORM_METHOD = 'single'; |
|
6 |
+%function extr = calculateImageData(voxelList,des,smoothed) |
|
7 |
+% global USE_DRIVE_CHECK_HACK; |
|
8 |
+ |
|
9 |
+% dtype='PSTH'; |
|
10 |
+ |
|
11 |
+% switch dtype |
|
12 |
+% case 'PSTH' |
|
13 |
+% V=des.xY.VY; |
|
14 |
+% case 'betas' |
|
15 |
+% V=des.Vbeta; |
|
16 |
+% end; |
|
17 |
+ |
|
18 |
+% if USE_DRIVE_CHECK_HACK |
|
19 |
+% if V(1).fname(1)~='D' |
|
20 |
+% for z=1:length(V) % Change Drive Letter - HACK! |
|
21 |
+% V(z).fname(1) = 'D'; |
|
22 |
+% end; |
|
23 |
+% end |
|
24 |
+% end |
|
25 |
+ |
|
26 |
+% if (~smoothed) |
|
27 |
+% for z=1:length(V) % Change smoothed Filename - HACK! |
|
28 |
+% % D:....SUBJECTID\session\swfanders... |
|
29 |
+% % D:....SUBJECTID\session\wfanders... |
|
30 |
+% tmp = findstr(filesep,V(z).fname); |
|
31 |
+% V(z).fname = strcat(V(z).fname(1:tmp(end)),V(z).fname(tmp(end)+2:end)); |
|
32 |
+% end; |
|
33 |
+% end |
|
6 | 34 |
|
7 | 35 |
V = filenameList; |
8 | 36 |
|
9 | 37 |
vox = voxelList; |
10 | 38 |
nVoxel = size(vox,1); |
11 | 39 |
nImage = numel(V); |
12 |
-nRoiFiles = ; |
|
13 | 40 |
|
14 | 41 |
for kImage=1:nImage |
15 |
- extr(kImage) = struct(... |
|
16 |
- 'dat', repmat(NaN, [1 nVoxel]),... |
|
17 |
- 'mean', repmat(NaN, [1 nVoxel]),... |
|
18 |
- 'sum', repmat(NaN, [1 nVoxel]),... |
|
19 |
- 'nvx', repmat(NaN, [1 nVoxel]),... |
|
20 |
- 'posmm', repmat(NaN, [3 nVoxel]),... |
|
21 |
- 'posvx', repmat(NaN, [3 nVoxel])); |
|
42 |
+% extr(kImage) = struct(... |
|
43 |
+% 'dat', ... |
|
44 |
+% 'val', repmat(NaN, [1 nVoxel]),... |
|
45 |
+% 'mean', repmat(NaN, [1 nVoxel]),... |
|
46 |
+% 'sum', repmat(NaN, [1 nVoxel]),... |
|
47 |
+% 'nvx', repmat(NaN, [1 nVoxel]),... |
|
48 |
+% 'posmm', repmat(NaN, [3 nVoxel]),... |
|
49 |
+% 'posvx', repmat(NaN, [3 nVoxel])); |
|
22 | 50 |
|
23 | 51 |
switch TRANSFORM_METHOD |
24 | 52 |
case 'single' |
... | ... |
@@ -44,10 +72,33 @@ for kImage=1:nImage |
44 | 72 |
end |
45 | 73 |
end |
46 | 74 |
|
75 |
+ |
|
76 |
+ for iVoxel = 1:nVoxel |
|
77 |
+ |
|
78 |
+% if rad==0 |
|
79 |
+ x = roicenter(1,iVoxel); |
|
80 |
+ y = roicenter(2,iVoxel); |
|
81 |
+ z = roicenter(3,iVoxel); |
|
82 |
+% else |
|
83 |
+% tmp = spm_imatrix(V(kImage).mat); |
|
84 |
+% vdim = tmp(7:9); |
|
85 |
+% vxrad = ceil((rad*ones(1,3))./(ones(nVoxel,1)*vdim))'; |
|
86 |
+% [x y z] = ndgrid(-vxrad(1,iVoxel):sign(vdim(1)):vxrad(1,iVoxel), ... |
|
87 |
+% -vxrad(2,iVoxel):sign(vdim(2)):vxrad(2,iVoxel), ... |
|
88 |
+% -vxrad(3,iVoxel):sign(vdim(3)):vxrad(3,iVoxel)); |
|
89 |
+% sel = (x./vxrad(1,iVoxel)).^2 + (y./vxrad(2,iVoxel)).^2 + ... |
|
90 |
+% (z./vxrad(3,iVoxel)).^2 <= 1; |
|
91 |
+% x = roicenter(1,iVoxel)+x(sel(:)); |
|
92 |
+% y = roicenter(2,iVoxel)+y(sel(:)); |
|
93 |
+% z = roicenter(3,iVoxel)+z(sel(:)); |
|
94 |
+% end; |
|
95 |
+ |
|
96 |
+ |
|
47 | 97 |
dat = spm_sample_vol(V(kImage), x, y, z,0); |
48 | 98 |
extr(kImage).dat(iVoxel) = dat; |
49 | 99 |
extr(kImage).mean(iVoxel) = nanmean(dat); |
50 | 100 |
extr(kImage).nvx(iVoxel) = numel(dat); |
51 | 101 |
end; |
52 | 102 |
|
103 |
+end; |
|
53 | 104 |
end |
54 | 105 |
\ No newline at end of file |
... | ... |
@@ -2,11 +2,6 @@ function main_UI(args) |
2 | 2 |
|
3 | 3 |
global CROSSVAL_METHOD_DEF; |
4 | 4 |
|
5 |
-% project = args.project; |
|
6 |
-% DEFAULT = project.default; |
|
7 |
- |
|
8 |
- % DELETE THIS when Project chooser is ready |
|
9 |
- |
|
10 | 5 |
DEFAULT.selectedSubject = 1; |
11 | 6 |
DEFAULT.smoothed = 1; |
12 | 7 |
DEFAULT.multisubject = 'single'; |
... | ... |
@@ -20,7 +15,6 @@ DEFAULT.frameshiftdur = 0; |
20 | 15 |
DEFAULT.classdefstring = 'left,\t[9,11,13],\t -2 ;\nright,\t[10,12,14],\t -1;'; |
21 | 16 |
DEFAULT.voxelstring = 'SPL l,\t[ 0, 0, 0];\nSPL r,\t[ 0, 0, 0];\n'; |
22 | 17 |
DEFAULT.svmoptstring = '-s 0 -t 0 -v 6 -c 1'; |
23 |
- % STOP DELETE HERE |
|
24 | 18 |
|
25 | 19 |
% Initialize and hide the GUI as it is being constructed. |
26 | 20 |
frameWidth=450; |
... | ... |
@@ -49,7 +43,8 @@ DEFAULT.svmoptstring = '-s 0 -t 0 -v 6 -c 1'; |
49 | 43 |
pCLASS = uipanel(frame,'Title','Class Definitions','Position',[0 optionLineHeight*9 frameWidth optionLineHeight*5]); |
50 | 44 |
pVOXEL = uipanel(frame,'Title','Voxel Selector', 'Position',[0 optionLineHeight*3 frameWidth optionLineHeight*6]); |
51 | 45 |
pSVM = uipanel(frame,'Title','SVM Options', 'Position',[0 optionLineHeight*1 frameWidth optionLineHeight*2]); |
52 |
- btnRunButton = uicontrol(frame,'Tag','run','String','run decode-performance visualiser','Position',[2 optionLineHeight*0 frameWidth controlElementHeight*1.6]); |
|
46 |
+ btnRunButton1 = uicontrol(frame,'Tag','Coord-Table','String','run coord-Table','Position',[2 optionLineHeight*0 (frameWidth/2) controlElementHeight*1.6]); |
|
47 |
+ btnRunButton2 = uicontrol(frame,'Tag','ROI-Image','String','run ROI-Image processing','Position',[2+(frameWidth/2) optionLineHeight*0 (frameWidth/2) controlElementHeight*1.6]); |
|
53 | 48 |
|
54 | 49 |
|
55 | 50 |
% Subject |
... | ... |
@@ -142,7 +137,9 @@ DEFAULT.svmoptstring = '-s 0 -t 0 -v 6 -c 1'; |
142 | 137 |
set(model.txtSVMopts,'Enable','on'); %inactive |
143 | 138 |
set(model.txtSVMopts,'HorizontalAlignment','left'); |
144 | 139 |
|
145 |
- set(btnRunButton,'Callback',{@cbRunSVM,model}); % set here, because of model. |
|
140 |
+ set(btnRunButton1,'Callback',{@cbRunCoordTable,model}); % set here, because of model. |
|
141 |
+ set(btnRunButton2,'Callback',{@cbRunROIImage,model}); % set here, because of model. |
|
142 |
+ set(btnRunButton2,'Enable','off'); |
|
146 | 143 |
uimenu(savemenu,'Label','Save','Callback',{@mcb_save,model}); |
147 | 144 |
uimenu(savemenu,'Label','Load','Callback',{@mcb_load,model}); |
148 | 145 |
|
... | ... |
@@ -158,22 +155,15 @@ function mcb_load(src,event,model) |
158 | 155 |
display('LOAD'); |
159 | 156 |
end |
160 | 157 |
|
161 |
-function sane = isSane(model) |
|
162 |
-% TODO |
|
163 |
-sane = 1; |
|
164 |
-end |
|
165 |
- |
|
166 |
-function cbRunSVM(src,evnt,model) |
|
167 |
- display('RUN'); |
|
168 |
- if isSane(model) |
|
169 |
-% classify(model) |
|
170 |
- main('all',model); |
|
171 |
- else |
|
172 |
- error('spmtoolbox:SVMCrossVal:paramcheck','please verify all parameters'); |
|
158 |
+function cbRunCoordTable(src,evnt,model) |
|
159 |
+ display('RUN Coord-Table Mode'); |
|
160 |
+ main('COORD-LOOKUP-TABLE',model); |
|
173 | 161 |
end |
162 |
+function cbRunROIImage(src,evnt,model) |
|
163 |
+ display('RUN Image-Mask Mode'); |
|
164 |
+ main('ROI-IMAGE-MASK', model); |
|
174 | 165 |
end |
175 | 166 |
|
176 |
- |
|
177 | 167 |
function label = createLabel(parent, pos, labelText) |
178 | 168 |
label = uicontrol(parent,'Style','text','String',labelText,'Position',pos); |
179 | 169 |
set(label,'HorizontalAlignment','left'); |
... | ... |
@@ -181,19 +171,9 @@ function label = createLabel(parent, pos, labelText) |
181 | 171 |
% set(label,'BackgroundColor','r'); |
182 | 172 |
end |
183 | 173 |
|
184 |
-function btn = createButton(parent,pos,tag,labelText,cbArgs) |
|
185 |
- btn = uicontrol(parent,'Position',pos,'String',labelText,'tag',tag); |
|
186 |
- set(btn,'Callback',{@cbParseVariable,cbArgs}); |
|
187 |
-% set(btn,'BackgroundColor','b'); |
|
188 |
-end |
|
189 | 174 |
|
190 | 175 |
function txt = createTextField(parent,pos,model) |
191 | 176 |
txt = uicontrol(parent,'Style','edit','String',model,'Position',pos); |
192 | 177 |
set(txt,'BackgroundColor','w'); |
193 | 178 |
end |
194 | 179 |
|
195 |
-function drpField = createDropDown(parent,pos,selectionModel) |
|
196 |
- drpField = uicontrol(parent,'Style','popupmenu','Position',pos); |
|
197 |
- set(drpField,'String',selectionModel.Strings); |
|
198 |
- set(drpField,'BackgroundColor','w'); |
|
199 |
-end |
... | ... |
@@ -1,29 +1,25 @@ |
1 |
-function classify(varargin) |
|
1 |
+function runCoordTable(timeline,varargin) |
|
2 | 2 |
|
3 | 3 |
global CROSSVAL_METHOD_DEF; |
4 | 4 |
global VOXEL_SELECTION_MODE_DEF; |
5 | 5 |
|
6 |
-switch nargin |
|
7 |
- case 1 |
|
8 | 6 |
paramModel = varargin{1}; |
9 | 7 |
%PROJECT_BASE_PATH = 'D:\Analyze\Stimolos'; |
10 | 8 |
PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot'; |
11 | 9 |
PROJECT_RESULT_PATH = 'results\SPM.mat'; |
12 |
- otherwise |
|
13 |
- error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model'); |
|
14 |
-end |
|
15 |
- |
|
16 |
- % timeline params (claculate and plot) |
|
17 |
- timelineParams = struct; |
|
18 | 10 |
|
19 |
- timelineParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart); % -20; |
|
20 |
- timelineParams.frameShiftEnd = getDouble(paramModel.txtFrameShiftEnd); %15; |
|
21 |
- timelineParams.decodeDuration = getDouble(paramModel.txtFrameShiftDur); |
|
22 |
- timelineParams.psthStart = getDouble(paramModel.txtPSTHStart); % -25; |
|
23 |
- timelineParams.psthEnd = getDouble(paramModel.txtPSTHEnd); % 20; |
|
24 |
- timelineParams.baselineStart = getDouble(paramModel.txtBaselineStart); % -22; |
|
25 |
- timelineParams.baselineEnd = getDouble(paramModel.txtBaselineEnd); % -20; |
|
26 | 11 |
|
12 |
+ % timeline params (claculate and plot) |
|
13 |
+ timelineParams = timeline; |
|
14 |
+ |
|
15 |
+% timelineParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart); % -20; |
|
16 |
+% timelineParams.frameShiftEnd = getDouble(paramModel.txtFrameShiftEnd); %15; |
|
17 |
+% timelineParams.decodeDuration = getDouble(paramModel.txtFrameShiftDur); |
|
18 |
+% timelineParams.psthStart = getDouble(paramModel.txtPSTHStart); % -25; |
|
19 |
+% timelineParams.psthEnd = getDouble(paramModel.txtPSTHEnd); % 20; |
|
20 |
+% timelineParams.baselineStart = getDouble(paramModel.txtBaselineStart); % -22; |
|
21 |
+% timelineParams.baselineEnd = getDouble(paramModel.txtBaselineEnd); % -20; |
|
22 |
+% |
|
27 | 23 |
% common params |
28 | 24 |
calculateParams = struct; |
29 | 25 |
|
... | ... |
@@ -51,7 +47,7 @@ end |
51 | 47 |
subjectSelection = getSubjectIDString(paramModel); |
52 | 48 |
calculateParams.subjectSelection = subjectSelection; |
53 | 49 |
|
54 |
- decode = claculateMultiSubjectDecodePerformance(timelineParams,calculateParams); |
|
50 |
+ decode = claculateMultiSubjectDecodePerformance(timelineParams,calculateParams,paramModel); |
|
55 | 51 |
|
56 | 52 |
display('Finished calculations.'); |
57 | 53 |
display('Plotting...'); |
... | ... |
@@ -77,8 +73,7 @@ end |
77 | 73 |
|
78 | 74 |
|
79 | 75 |
%% subject loop |
80 |
-function decode = claculateMultiSubjectDecodePerformance(timelineParams,calculateParams) |
|
81 |
-global VOXEL_SELECTION_MODE_DEF; |
|
76 |
+function decode = claculateMultiSubjectDecodePerformance(timelineParams,calculateParams,paramModel) |
|
82 | 77 |
|
83 | 78 |
decode = struct; |
84 | 79 |
decode.decodePerformance = []; |
... | ... |
@@ -96,21 +91,9 @@ for subjectCell = calculateParams.subjectSelection |
96 | 91 |
subjectParams = struct; |
97 | 92 |
|
98 | 93 |
subjectParams.des = spm.SPM; |
99 |
- smoothed = calculateParams.smoothed; |
|
100 |
- |
|
101 |
- DataImageFilenames = getImageFileList(des,~smoothed); |
|
102 |
- subjectParams.voxelList = getTransformedCoordinates(... |
|
103 |
- calculateParams.VOXEL_SELECTION_MODE, |
|
104 | 94 |
|
105 |
- switch calculateParams.VOXEL_SELECTION_MODE |
|
106 |
- case VOXEL_SELECTION_MODE_DEF.manualGui |
|
107 |
- parsedVoxelList = parseVoxelList(paramModel,SubjectID); |
|
108 |
- = transformVoxelList(parsedVoxelList); |
|
109 | 95 |
|
110 |
- |
|
111 |
- case VOXEL_SELECTION_MODE_DEF.roiImage |
|
112 |
- subjectParams.voxelList = readRoiImage(); % image for subject! |
|
113 |
- end |
|
96 |
+ subjectParams.voxelList = parseVoxelList(paramModel,SubjectID); |
|
114 | 97 |
|
115 | 98 |
|
116 | 99 |
subjectParams.SubjectID = SubjectID; |
117 | 100 |