Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions AtlasViewerGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ function ParseArgs(args)
atlasViewer.dirnameAtlas = getAtlasDir(args);
end
if length(args)>3
atlasViewer.handles.dataTree = args{4};
atlasViewer.dataTree = get(atlasViewer.handles.dataTree, 'userdata');
if sum(isgraphics(args{4}))
atlasViewer.handles.dataTree = args{4};
atlasViewer.dataTree = get(atlasViewer.handles.dataTree, 'userdata');
end
end

% Change current folder to dirnameSubj and load data
Expand Down Expand Up @@ -651,7 +653,7 @@ function pushbuttonRegisterProbeToSurface_Callback(hObject, eventdata, handles)
refpts = set_eeg_active_pts(refpts, [], false);

% Finish registration
if isPreRegisteredProbe(probe, refpts)
if 0 %isPreRegisteredProbe(probe, refpts)

% Register probe by simply pulling (or pushing) optodes toward surface
% toward (or away from) center of head.
Expand Down
14 changes: 10 additions & 4 deletions Labelssurf/getLabelssurf.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
end
dirname = [dirname0 'anatomical/'];

if exist([dirname 'labelssurf2vol.txt'],'file')
T_2vol = load([dirname 'labelssurf2vol.txt'],'ascii');
labelssurf.T_2vol = T_2vol;
end


if exist([dirname 'labelssurf.mat'],'file')
load([dirname 'labelssurf.mat'],'-mat');
else
Expand All @@ -33,9 +39,9 @@
end

load([dirname 'labelssurf.mat']);
if exist([dirname 'labelssurf2vol.txt'],'file')
T_2vol = load([dirname 'labelssurf2vol.txt'],'ascii');
end
% if exist([dirname 'labelssurf2vol.txt'],'file')
% T_2vol = load([dirname 'labelssurf2vol.txt'],'ascii');
% end

fv = struct('vertices',[],'faces',[]);
idxL = [];
Expand Down Expand Up @@ -65,7 +71,7 @@
labelssurf.colormaps = cm;
labelssurf.colormapsIdx = 4;
labelssurf.idxL = idxL;
labelssurf.T_2vol = T_2vol;
% labelssurf.T_2vol = T_2vol;


if ~labelssurf.isempty(labelssurf)
Expand Down
20 changes: 20 additions & 0 deletions Labelssurf/saveLabelSurf2Vol.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function saveLabelSurf2Vol(headvol)
% Author:Sreekanth Kura ([email protected])

% I am assuming imported anatomy will be saved in RAS orientation.
S = size(headvol.img);
T = headvol.T_2ras;
Tras_2vol = T;
for u = 1:3
if sum(Tras_2vol(u,1:3)) == -1
Tras_2vol(u,4) = S(u);
else
Tras_2vol(u,4) = 0;
end
end

Tras_mni = (Tras_2vol'*T')';
Tmni_ras = inv(Tras_mni);
dirname = [headvol.pathname, '/anatomical/'];
filename = [dirname 'labelssurf2vol.txt'];
writematrix(Tmni_ras,filename,'Delimiter',' ')
5 changes: 4 additions & 1 deletion Probe/isPreRegisteredProbe.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@
end
if probeHasSpringRegistration(probe)
refpts1.labels = probe.registration.al(:,2);
refpts1.pos = probe.optpos(cell2array(probe.registration.al(:,1)), :);
refpts1.pos = probe.optpos_reg(cell2array(probe.registration.al(:,1)), :);
catch
d = 1;
end
else
refpts1 = probe.registration.refpts;
end
Expand Down
1 change: 1 addition & 0 deletions Utils/fs2viewer/ImportMriAnatomy.m
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ function ImportMriAnatomy_CloseRequestFcn(~, ~, handles)
saveHeadvol(headvol);
saveHeadsurf(headsurf);
savePialsurf(pialsurf);
saveLabelSurf2Vol(headvol);

catch ME

Expand Down
21 changes: 18 additions & 3 deletions Utils/fs2viewer/segment_head_vols.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,27 @@
end

% Align layer volume with head volume
X = inv(layer.vox2ras) * head.vox2ras;
layer.vol = xform_apply_vol_smooth(layer.vol, X);
X = inv(inv(layer.vox2ras) * head.vox2ras);
% layer.vol = xform_apply_vol_smooth(layer.vol, X);

tform = affinetform3d(X);
% layer.vol = imwarp(layer.vol,tform,'OutputView',imref3d(size(head.vol)));

% Assign layer segmentation number
s = max(hseg(:))+1;
layer_i = find(layer.vol ~= 0);
% layer_i = find(layer.vol ~= 0);

ind = find(layer.vol ~=0);
[I1,I2,I3] = ind2sub(size(layer.vol),ind);
t_ind = round([I1 I2 I3 ones(size(I1))]*X');
idx = find(t_ind(:,1) < 1 | t_ind(:,1) > size(head.vol,1));
t_ind(idx,:) = [];
idx = find(t_ind(:,2) < 1 | t_ind(:,2) > size(head.vol,2));
t_ind(idx,:) = [];
idx = find(t_ind(:,3) < 1 | t_ind(:,3) > size(head.vol,3));
t_ind(idx,:) = [];
layer_i = sub2ind(size(head.vol),t_ind(:,1),t_ind(:,2),t_ind(:,3));

hseg(layer_i) = s;
tiss_type{s}=name;

Expand Down