kleine änderungen code move
Christoph Budziszewski authored 15 years ago
|
1) function pst = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,eventList,data,sessionList)
2) bstart = baselineStart;
3) bend = baselineEnd;
4) edur = 12;
5) pre = globalStart;
6) post = globalEnd;
7) res = 1;
8)
9) normz = 'file';
10) pm = 0;
11)
12) lsess = getNumberOfScans(des);
13) nSessions = getNumberOfSessions(des);
14) tr = 2;
15)
16) [evntrow evntcol]=size(eventList);
17)
18)
19) hsec=str2num(des.xsDes.High_pass_Filter(8:end-3)); % Highpass filter [sec] from SPM.mat
20)
21) if strcmp(des.xBF.UNITS,'secs')
22) unitsecs=1;
23) end;
24)
25) nScansPerSession=getNumberOfScans(des);
26) %stime=[0:tr:max(nScansPerSession)*tr+post-tr]; % Stimulus time for raw data plot
27) stime=0:tr:max(nScansPerSession)*tr+round(post/tr)*tr-tr; % Stimulus time for raw data plot
28)
29)
30)
31) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32) % RUN
33) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34)
35)
36) % Digital Highpass
37) Rp=0.5;
38) Rs=20;
39) NO=1;
40) Wp=1/((1/2/tr)/(1/hsec));
41) [B, A] = ellip(NO,Rp,Rs,Wp,'high');
42)
43) sdata(1:max(nScansPerSession)+round(post/tr),1:nSessions)=nan; % Open Data Matrix
44) for z=1:nSessions % Fill Data Matrix sessionwise
45) sdata(1:nScansPerSession(z),z)=data(sum(nScansPerSession(1:z))-nScansPerSession(z)+1:sum(nScansPerSession(1:z)))';
46) end;
47) % usdata=sdata; % Keep unfiltered data
48)
49) sdatamean=nanmean(nanmean(sdata(:,:)));
50) for z=1:nSessions
51) % X(:,z)=[1:1:max(nScansPerSession)]'; % #Volume
52) sdata(1:nScansPerSession(z),z)=filtfilt(B,A,sdata(1:nScansPerSession(z),z)); %Filter Data (Highpass)
53) end;
54) sdata=sdata+sdatamean;
55)
56)
57) %%%%Parametric Modulation Modus%%%%
58) if pm %Find Parameters for Event of Interest
59) [imods modss mods erow evntrow eventList] = getParametricMappingEvents(eventList,evntrow,des,pmf);
60) end;
61) %%%%PM%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62)
63)
64) for zr=1:evntrow
65) n{zr}=0;
66) nn{zr}=0;
67) nnn{zr}=0;
68) sstart{zr}=1;
69) end;
70)
71)
72) sesst0=0;
73) for sessionID=sessionList
74) if sessionID>1
75) sesst0(sessionID)=sum(lsess(1:sessionID-1))*tr;
76) end;
77) for zr=1:evntrow %LABEL NUMBER, EVENT GROUP
78) sstart{zr}=n{zr}+1;
79) for ze=1:evntcol % EVENT INDEX in EventList
80) if ze==1 || (ze>1 && eventList(zr,ze)~=eventList(zr,ze-1))
81) for zz=1:length(des.Sess(sessionID).U(eventList(zr,ze)).ons) % EVENT REPETITION NUMBER
82) if ~unitsecs
83) des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)=(des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)-1)*tr;
84) des.Sess(sessionID).U(eventList(zr,ze)).dur(zz)=(des.Sess(sessionID).U(eventList(zr,ze)).dur(zz)-1)*tr;
85) end;
86)
87) nnn{zr}=nnn{zr}+1; % INFO for rawdataplot start
88) if des.Sess(sessionID).U(eventList(zr,ze)).dur(zz)<edur
89) mev{zr}(nnn{zr},1:2)=[des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)+sesst0(sessionID) edur]; % modeled event [onset length]
90) else
91) mev{zr}(nnn{zr},1:2)=[des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)+sesst0(sessionID) des.Sess(sessionID).U(eventList(zr,ze)).dur(zz)];
92) end; % INFO for rawdataplot end
93)
94) n{zr}=n{zr}+1;
95) pst{zr}(n{zr},:)=interp1(stime,sdata(:,sessionID),[des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)+pre:res:des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)+post],'linear');
96) if strcmp(normz,'epoc')
97) bline=nanmean(pst{zr}(n{zr},round(-pre/res+(bstart)/res+1):round(-pre/res+(bend)/res+1)));
98) if isnan(bline)
99) pst{zr}(n{zr},1:-pre/res+post/res+1)=nan;
100) else
101) % nn{zr}=nn{zr}+1;
102) pst{zr}(n{zr},:)=(pst{zr}(n{zr},:)-bline)/bline*100; % 'epoch-based' normalization
103) end;
104) end;
105) end;
106) end;
107) end;
108) if ~strcmp(normz,'epoc')
109) bline(zr)=nanmean(nanmean(pst{zr}(sstart{zr}:n{zr},-pre/res+(bstart)/res+1:-pre/res+(bend)/res+1)));
110) bstd(zr)=nanmean(nanstd(pst{zr}(sstart{zr}:n{zr},-pre/res+(bstart)/res+1:-pre/res+(bend)/res+1)));
111) nn{zr}=n{zr};
112) end;
113) end;
114) if strcmp(normz,'filz')
115) for zr=1:evntrow
116) pst{zr}(sstart{zr}:n{zr},:)=(pst{zr}(sstart{zr}:n{zr},:)-mean(bline))/mean(bstd); % session-based z-score normalization
117) end;
118) elseif strcmp(normz,'file')
119) for zr=1:evntrow
120) pst{zr}(sstart{zr}:n{zr},:)=(pst{zr}(sstart{zr}:n{zr},:)-mean(bline))/mean(bline)*100; % session-based normalization
121) end;
122) end;
123) end;
|