Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8c38760

Browse files
committedMar 27, 2019
v1.9.3
-- Made display of patches of automatically excluded time points from motion correction work
1 parent 696e73b commit 8c38760

File tree

8 files changed

+179
-1
lines changed

8 files changed

+179
-1
lines changed
 

‎DataTree/ProcStream/ProcInputClass.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ function SetTincMan(obj, val)
384384
function val = GetTincMan(obj)
385385
val = obj.tIncMan;
386386
end
387+
387388
end
388389

389390

‎DataTree/ProcStream/ProcResultClass.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ function SetNtrials(obj, val)
337337
end
338338

339339

340+
% ----------------------------------------------------------------------------------
341+
function val = GetTincAuto(obj)
342+
val = [];
343+
if isproperty(obj.misc, 'tIncAuto')
344+
val = obj.misc.tIncAuto;
345+
end
346+
end
347+
340348
end
341349

342350

‎DataTree/RunClass.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,19 @@ function SetCondName2Group(obj, CondNamesGroup)
320320
aux = obj.acquired.GetAux();
321321
end
322322

323+
324+
% ----------------------------------------------------------------------------------
325+
function tIncAuto = GetTincAuto(obj)
326+
tIncAuto = obj.procStream.output.GetTincAuto();
327+
end
328+
329+
330+
% ----------------------------------------------------------------------------------
331+
function tIncMan = GetTincMan(obj)
332+
tIncMan = obj.procStream.input.GetTincMan();
333+
end
334+
335+
323336
end % Public Set/Get methods
324337

325338

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function DisplayExcludedTime(mode,col)
2+
global hmr
3+
4+
tInc = hmr.dataTree.currElem.GetTincAuto();
5+
t = hmr.dataTree.currElem.GetTime();
6+
7+
if isempty(tInc)
8+
return;
9+
end
10+
11+
if ~exist('mode','var') || isempty(mode)
12+
mode = 'auto';
13+
end
14+
if strcmp(mode,'manual') || ~exist('col')
15+
col = setColor(mode);
16+
end
17+
18+
% Patch in some versions of matlab messes up the renreder, that is it changes the
19+
% renderer property. Therefore we save current renderer before patch to
20+
% restore it to what it was to pre-patch time.
21+
renderer = get(gcf, 'renderer');
22+
23+
hold on
24+
p = timeExcludeRanges(tInc,t);
25+
yy = ylim();
26+
for ii=1:size(p,1)
27+
h = patch([p(ii,1) p(ii,2) p(ii,2) p(ii,1) p(ii,1)], [yy(1) yy(1) yy(2) yy(2) yy(1)], col, ...
28+
'facealpha',0.3, 'edgecolor','none' );
29+
end
30+
hold off
31+
32+
% Restore previous renderer
33+
set(gcf, 'renderer', renderer);
34+
35+
36+
37+
% -------------------------------------------------------------------------
38+
function col = setColor(mode)
39+
40+
% Set patches color based on figure renderer
41+
42+
if strcmp(get(gcf,'renderer'),'zbuffer')
43+
if strcmp(mode,'auto')
44+
col=[1.0 0.5 0.5];
45+
else
46+
col=[1.0 0.5 1.0];
47+
end
48+
else
49+
if strcmp(mode,'auto')
50+
col=[1.0 0.0 0.0];
51+
else
52+
col=[1.0 0.0 1.0];
53+
end
54+
end

‎GuiMain/AxesData/timeExcludeRanges.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function p = timeExcludeRanges(tInc,t)
2+
3+
p=[];
4+
mdiff = diff(tInc);
5+
tidx1 = find(mdiff==-1);
6+
tidx2 = find(mdiff==1);
7+
8+
% If excluded time points are at the extremes of the time range,
9+
% then add inflections at the beginning or end.
10+
if tInc(1)==0
11+
tidx1 = [1;tidx1];
12+
end
13+
if tInc(end)==0
14+
tidx2 = [tidx2;length(tInc)];
15+
end
16+
% if ~isempty(tidx2) && isempty(find(tidx1<tidx2(1)))
17+
% tidx1 = [1; tidx1];
18+
% end
19+
% if ~isempty(tidx1) && isempty(find(tidx2>tidx1(end)))
20+
% tidx2 = [tidx2; length(tInc)];
21+
% end
22+
23+
for ii=1:length(tidx1)
24+
if ii<=length(tidx2)
25+
p(ii,:) = [t(tidx1(ii)) t(tidx2(ii))];
26+
else
27+
p(ii,:) = [t(tidx1(ii)) t(end)];
28+
end
29+
end

‎Homer3.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ function DisplayData(handles)
798798
end
799799
DisplayAxesSDG();
800800
DisplayStim(handles);
801+
DisplayExcludedTime();
802+
801803

802804

803805
% ----------------------------------------------------------------------------------

‎Utils/getVernum.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function vrnnum = getVernum()
22

33
vrnnum{1} = '1.9'; % Major version number
4-
vrnnum{2} = '2'; % Minor version number
4+
vrnnum{2} = '3'; % Minor version number
55
vrnnum{3} = ''; % Patch #: 'p1', 'p2', etc

‎Utils/simulateGroupData.m

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
function simulateGroupData(template, groupname, nsubj, nruns)
2+
3+
%
4+
% Usage:
5+
%
6+
% simulateGroupData(template, groupname, nsubj, nruns)
7+
%
8+
% Description:
9+
%
10+
% Generate a group of .nirs files from one .nirs file used as a template; the group
11+
% consists of nsubj number of subjects and nruns number of runs in each subject. The
12+
% data for the generated .nirs files is based on the data from the data file to which
13+
% a random component is added.
14+
%
15+
% Example 1:
16+
%
17+
% Generate a group named group1 based on data from the file ./template. This group
18+
% should have 4 subjects with 2, 1, 3 and 3 runs in the 4 subjects respectively.
19+
% Note: ./template is in our data directory but we don't want to be part of the
20+
% group so we rename it to be without the .nirs extensionto avoid moving it out of
21+
% the directory.
22+
%
23+
% simulateGroupData('./template','group1',4,[2,1,3,3])
24+
%
25+
%
26+
27+
if length(nruns)~=nsubj
28+
nruns=ones(1,nsubj)*nruns(1);
29+
end
30+
if ~exist('rcoeff','var') || (exist('rcoeff','var') && length(rcoeff)<nsubj)
31+
rcoeff = ones(nsubj,1)*50;
32+
end
33+
34+
load(template,'-mat');
35+
if exist('aux10')
36+
aux=aux10;
37+
end
38+
39+
if isempty(groupname)
40+
k1=[findstr(template,'/') findstr(template,'\')];
41+
k1=sort(k1);
42+
template=template(k1(end)+1:end);
43+
k2=findstr(template,'.nirs');
44+
subjname=template(1:k2-1);
45+
else
46+
subjname=groupname;
47+
end
48+
49+
d0=d;
50+
for jj=1:nsubj
51+
for ii=1:nruns(jj)
52+
dmean = mean(d(:))/10;
53+
dr=dmean.*rand(size(d,1),size(d,2));
54+
d=d0+dr;
55+
kk=ii;
56+
while 1
57+
if(kk>9)
58+
filename = [subjname '_run' num2str(kk) '.nirs'];
59+
else
60+
filename = [subjname '_run0' num2str(kk) '.nirs'];
61+
end
62+
if exist(filename,'file')
63+
kk=kk+1;
64+
continue;
65+
else
66+
break;
67+
end
68+
end
69+
save(filename, '-mat', 'SD', 't', 'd', 's','aux');
70+
end
71+
end

0 commit comments

Comments
 (0)
Please sign in to comment.