Christoph Budziszewski commited on 2009-02-09 16:44:50
Zeige 10 geänderte Dateien mit 64 Einfügungen und 15 Löschungen.
git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@127 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... | ... |
@@ -0,0 +1,15 @@ |
1 |
+function dirs = listDirs(wd) |
|
2 |
+% d = listDirs(dir) returns all directories below dir as a cell array. |
|
3 |
+% the Structure is the same as from the 'dir' command (because this |
|
4 |
+% function relies on 'dir' |
|
5 |
+% . and .. are filterd. no intetion to include an option switch for those |
|
6 |
+% special dirs. |
|
7 |
+allfiles = dir(wd); |
|
8 |
+nDirs = 1; |
|
9 |
+for i = 1:size(allfiles) |
|
10 |
+ file = allfiles(i); |
|
11 |
+ if file.isdir && file.name(1)~='.' |
|
12 |
+ dirs{nDirs}=file; |
|
13 |
+ nDirs = nDirs +1; |
|
14 |
+ end |
|
15 |
+end |
... | ... |
@@ -15,9 +15,13 @@ for subjectCell = loadParams.subjectCellArray |
15 | 15 |
|
16 | 16 |
datastruct.(subjectString).images = getImageFileList(des,loadParams.use_smoothed_image_hack); |
17 | 17 |
|
18 |
+ subjectPath = fullfile(getStudyBasePath(loadParams.StudyID),SubjectID); |
|
19 |
+ |
|
18 | 20 |
ROIIMAGE = 1; |
19 | 21 |
if ROIIMAGE |
20 | 22 |
%load ROI Image Header |
21 |
- datastruct.(subjectString).roiImages = readRoiImage(sprintf('Select ROI Images for Subject %s',SubjectID)); |
|
23 |
+% wd = 'C:\Dokumente und Einstellungen\Christoph\Eigene Dateien\Diplomarbeit\data'; |
|
24 |
+ wd = subjectPath; |
|
25 |
+ datastruct.(subjectString).roiImages = readRoiImage(sprintf('Select ROI Images for Subject %s',SubjectID),wd); |
|
22 | 26 |
end |
23 | 27 |
end |
24 | 28 |
\ No newline at end of file |
... | ... |
@@ -4,7 +4,8 @@ switch action |
4 | 4 |
case 'COORD-LOOKUP-TABLE' |
5 | 5 |
runCoordTable(timeline,parameterModel); |
6 | 6 |
case 'ROI-IMAGE-MASK' |
7 |
- runROIImageMaskMode(parameterModel) |
|
7 |
+ runROIImageMaskMode(parameterModel); |
|
8 |
+ disp('DONE'); |
|
8 | 9 |
case 'FULL-BRAIN' |
9 | 10 |
error('SVMCrossVal:main:notImplemented','Feature not yet implemented'); |
10 | 11 |
otherwise |
... | ... |
@@ -12,17 +13,7 @@ switch action |
12 | 13 |
end |
13 | 14 |
end |
14 | 15 |
|
15 |
-function runROIImageMaskMode(parameterModel) |
|
16 |
- loadParams.StudyID = 'CHOICE24'; |
|
17 |
- loadParams.use_smoothed_image_hack = 1; |
|
18 |
- loadParams.subjectCellArray = getSubjectIDString(parameterModel); |
|
19 | 16 |
|
20 |
- imageStruct = loadImageFileNamesData(loadParams); |
|
21 |
- assignin('base','imageStruct',imageStruct); |
|
22 |
- |
|
23 |
-% coordinateStruct = computeCoordinates(imageStruct); |
|
24 |
-% assignin('base','coordinateStruct',coordinateStruct); |
|
25 |
-end |
|
26 | 17 |
|
27 | 18 |
% generate parameter structs for subroutines |
28 | 19 |
function timelineParams = getTimeLineParams(paramModel) |
... | ... |
@@ -139,7 +139,7 @@ DEFAULT.svmoptstring = '-s 0 -t 0 -v 6 -c 1'; |
139 | 139 |
|
140 | 140 |
set(btnRunButton1,'Callback',{@cbRunCoordTable,model}); % set here, because of model. |
141 | 141 |
set(btnRunButton2,'Callback',{@cbRunROIImage,model}); % set here, because of model. |
142 |
- set(btnRunButton2,'Enable','off'); |
|
142 |
+% set(btnRunButton2,'Enable','off'); |
|
143 | 143 |
uimenu(savemenu,'Label','Save','Callback',{@mcb_save,model}); |
144 | 144 |
uimenu(savemenu,'Label','Load','Callback',{@mcb_load,model}); |
145 | 145 |
|
... | ... |
@@ -1,4 +1,3 @@ |
1 |
-function imageList = readRoiImage(formatstring) |
|
2 |
-wd = 'C:\Dokumente und Einstellungen\Christoph\Eigene Dateien\Diplomarbeit\data'; |
|
1 |
+function imageList = readRoiImage(formatstring,wd) |
|
3 | 2 |
imageList = spm_vol(spm_select([1 Inf],'image',formatstring,[],wd)); |
4 | 3 |
end |
5 | 4 |
\ No newline at end of file |
... | ... |
@@ -0,0 +1,40 @@ |
1 |
+function runROIImageMaskMode(parameterModel) |
|
2 |
+ loadParams.StudyID = 'CHOICE24'; |
|
3 |
+ loadParams.use_smoothed_image_hack = 1; |
|
4 |
+ loadParams.subjectCellArray = getSubjectIDString(parameterModel); |
|
5 |
+ |
|
6 |
+ imageStruct = loadImageFileNamesData(loadParams); |
|
7 |
+ assignin('base','imageStruct',imageStruct); |
|
8 |
+ |
|
9 |
+% coordinateStruct = computeCoordinates(imageStruct); |
|
10 |
+% assignin('base','coordinateStruct',coordinateStruct); |
|
11 |
+end |
|
12 |
+ |
|
13 |
+function extr = claculateRoiImageData(filenameList,roiImageList) |
|
14 |
+ |
|
15 |
+V = filenameList; |
|
16 |
+nImage = numel(V); |
|
17 |
+Vm = roiImageList; |
|
18 |
+nRoi = numel(Vm); |
|
19 |
+for kImage=1:nImage |
|
20 |
+ x = []; y = []; z = []; |
|
21 |
+ for iRoiFile = 1:nRoi |
|
22 |
+ [x1 y1] = ndgrid(1:V(k).dim(1),1:V(k).dim(2)); |
|
23 |
+ for p = 1:V(k).dim(3) % resample mask Vm(i) in space of V(k) |
|
24 |
+ B = spm_matrix([0 0 -p 0 0 0 1 1 1]); |
|
25 |
+ M = inv(B*inv(V(k).mat)*Vm(iRoiFile).mat); |
|
26 |
+ msk = find(spm_slice_vol(Vm(iRoiFile),M,V(k).dim(1:2),0)); |
|
27 |
+ if ~isempty(msk) |
|
28 |
+ z1 = p*ones(size(msk(:))); |
|
29 |
+ x = [x; x1(msk(:))]; |
|
30 |
+ y = [y; y1(msk(:))]; |
|
31 |
+ z = [z; z1]; |
|
32 |
+ end |
|
33 |
+ end |
|
34 |
+ dat = spm_sample_vol(V(k), x, y, z,0); |
|
35 |
+ |
|
36 |
+ extr(kImage).dat(iRoiFile) = dat; |
|
37 |
+ end |
|
38 |
+end |
|
39 |
+ |
|
40 |
+end |
|
0 | 41 |
\ No newline at end of file |
1 | 42 |