Skip to content

Commit

Permalink
Convis now only updates elvis when pressing apply.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreashorn committed Sep 30, 2016
1 parent 4f947ee commit 3295130
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 157 deletions.
4 changes: 2 additions & 2 deletions connectomics/cv_build_graph_fig.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@
end


pgraphsurf=ea_showconnectivitypatch(resultfig,parc,tparc.img,0,atlas_lgnd{2},ptnodeix,'autumn');
pgraphsurf=ea_showconnectivitypatch(resultfig,parc,tparc.img,0,atlas_lgnd{2},ptnodeix,'autumn',get(handles.wmatnodes,'Value'),get(handles.wmatlabs,'Value'));

ngraphsurf=ea_showconnectivitypatch(resultfig,parc,tparc.img*-1,0,atlas_lgnd{2},ntnodeix,'winter');
ngraphsurf=ea_showconnectivitypatch(resultfig,parc,tparc.img*-1,0,atlas_lgnd{2},ntnodeix,'winter',get(handles.wmatnodes,'Value'),get(handles.wmatlabs,'Value'));

end
% export structures as ML
Expand Down
Binary file modified connectomics/ea_convis.fig
Binary file not shown.
218 changes: 140 additions & 78 deletions connectomics/ea_convis.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

% Edit the above text to modify the response to help ea_convis

% Last Modified by GUIDE v2.5 06-Jun-2016 18:04:32
% Last Modified by GUIDE v2.5 30-Sep-2016 17:26:59

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
Expand Down Expand Up @@ -76,9 +76,13 @@ function ea_convis_OpeningFcn(hObject, eventdata, handles, varargin)
function refreshcv(varargin)
handles=varargin{1};
hold=0; % do refresh seed coordinates
apply=0;
if nargin>1
hold=varargin{2};
end
if nargin>2
apply=varargin{3};
end


options=getappdata(handles.convis,'options');
Expand Down Expand Up @@ -114,47 +118,47 @@ function refreshcv(varargin)
cv_enabletime(handles);
end


%% retrieve and delete prior results
resultfig=ea_cvcleanup(handles);
if apply % update elvis
%% retrieve and delete prior results
resultfig=ea_cvcleanup(handles);
pV=getappdata(handles.convis,'pV');
pX=getappdata(handles.convis,'pX');
ea_deleteML(resultfig,handles,options);
if ~hold
[xmm,ymm,zmm]=getcoordinates(pV,pX,get(handles.matseed,'Value'));
set(handles.xmm,'String',num2str(xmm)); set(handles.ymm,'String',num2str(ymm)); set(handles.zmm,'String',num2str(zmm));
set(handles.matseed,'ForegroundColor',[0,0,0]);
end

%% now show results
if get(handles.vizvat,'Value'); % show voxel-level results
ea_cvshowvatresults(resultfig,pX,directory,filesare,handles,pV,selectedparc,options);
else
ea_deletePL(resultfig,'PL','vat');
end

if get(handles.vizgraph,'Value'); % show voxel-level results
ea_cvshowvoxresults(resultfig,directory,filesare,handles,pV,selectedparc,options);
end

if get(handles.vizmat,'Value'); % show seed-based-connectivity results
if ~hold
[xmm,ymm,zmm]=getcoordinates(pV,pX,get(handles.matseed,'Value'));
set(handles.xmm,'String',num2str(xmm)); set(handles.ymm,'String',num2str(ymm)); set(handles.zmm,'String',num2str(zmm));
set(handles.matseed,'ForegroundColor',[0,0,0]);
end

ea_cvshowseedbasedresults(resultfig,directory,pV,pX,selectedparc,handles,options);
else
ea_deletePL(resultfig,'PL','mat');
end


if get(handles.wmatedges,'Value') || get(handles.wmatnodes,'Value'); % show matrix-level results
ea_cvshowmatresults(resultfig,directory,selectedparc,handles,options);
end

if (get(handles.vizmat,'Value') || get(handles.vizvat,'Value')) && get(handles.timecircle,'Value') && strcmp(get(handles.timecircle,'Enable'),'on') % cycle over time..
pause(0.1);
%% now show results
if get(handles.vizvat,'Value'); % show voxel-level results
ea_cvshowvatresults(resultfig,pX,directory,filesare,handles,pV,selectedparc,options);
else
ea_deletePL(resultfig,'PL','vat');
end

if get(handles.vizgraph,'Value'); % show voxel-level results
ea_cvshowvoxresults(resultfig,directory,filesare,handles,pV,selectedparc,options);
end

refreshcv(handles);
if get(handles.vizmat,'Value'); % show seed-based-connectivity results

ea_cvshowseedbasedresults(resultfig,directory,pV,pX,selectedparc,handles,options);
else
ea_deletePL(resultfig,'PL','mat');
end


if get(handles.wmatedges,'Value') || get(handles.wmatnodes,'Value'); % show matrix-level results
ea_cvshowmatresults(resultfig,directory,selectedparc,handles,options);
end

if (get(handles.vizmat,'Value') || get(handles.vizvat,'Value')) && get(handles.timecircle,'Value') && strcmp(get(handles.timecircle,'Enable'),'on') % cycle over time..
pause(0.1);

refreshcv(handles);
end
end

set(convis,'name','Connectome Results');

function ea_deleteML(resultfig,handles,options)
Expand Down Expand Up @@ -221,7 +225,7 @@ function ea_cvshowvoxresults(resultfig,directory,filesare,handles,pV,selectedpar
thresh=str2double(thresh);
end
set(handles.voxthreshis,'String',num2str(thresh));
graphsurf=ea_showconnectivitypatch(resultfig,gV,gX,thresh);
graphsurf=ea_showconnectivitypatch(resultfig,gV,gX,thresh,[],[],[],1,0);

setappdata(resultfig,'graphsurf',graphsurf);

Expand All @@ -238,37 +242,37 @@ function ea_cvshowseedbasedresults(resultfig,directory,pV,pX,selectedparc,handle
ea_cvshowmatresultsCMTC(resultfig,directory,pV,pX,handles,options);
else % use fiberset

% fibers filename
switch matmodality
case 'Patient-specific fiber tracts'
fibersfile=[directory,options.prefs.FTR_normalized];
otherwise
fibersfile=[ea_getconnectomebase('dmri'),matmodality,'.mat'];
end

% seed filename
seed=ea_load_nii([options.earoot,'templates',filesep,'labeling',filesep,selectedparc,'.nii']);
% delete everything but set selected parcellation to 1.
oseed=seed.img;
seed.img(:)=0;
seed.img(round(oseed)==get(handles.matseed,'Value'))=1;

targetsfile=ea_load_nii([options.earoot,'templates',filesep,'labeling',filesep,selectedparc,'.nii']);
targetsfile.img(round(targetsfile.img)==get(handles.matseed,'Value'))=0;
thresh=get(handles.matthresh,'String');
options.writeoutstats=0;
options.writeoutpm=1;

% fibers filename
switch matmodality
case 'Patient-specific fiber tracts'
fibersfile=[directory,options.prefs.FTR_normalized];
otherwise
fibersfile=[ea_getconnectomebase('dmri'),matmodality,'.mat'];
end

% seed filename
seed=ea_load_nii([options.earoot,'templates',filesep,'labeling',filesep,selectedparc,'.nii']);
% delete everything but set selected parcellation to 1.
oseed=seed.img;
seed.img(:)=0;
seed.img(round(oseed)==get(handles.matseed,'Value'))=1;

targetsfile=ea_load_nii([options.earoot,'templates',filesep,'labeling',filesep,selectedparc,'.nii']);
targetsfile.img(round(targetsfile.img)==get(handles.matseed,'Value'))=0;
thresh=get(handles.matthresh,'String');
options.writeoutstats=0;
options.writeoutpm=1;


[changedstates,ret]=ea_checkfschanges(resultfig,fibersfile,seed,targetsfile,thresh,'mat');

if ~ret % something has changed since last time.
ea_deletePL(resultfig,'PL','mat');

[changedstates,ret]=ea_checkfschanges(resultfig,fibersfile,seed,targetsfile,thresh,'mat');
[~,thresh]=ea_cvshowfiberconnectivities(resultfig,fibersfile,seed,targetsfile,thresh,1,options,'',changedstates,'mat');
set(handles.matthreshis,'String',num2str(thresh));

if ~ret % something has changed since last time.
ea_deletePL(resultfig,'PL','mat');

[~,thresh]=ea_cvshowfiberconnectivities(resultfig,fibersfile,seed,targetsfile,thresh,1,options,'',changedstates,'mat');
set(handles.matthreshis,'String',num2str(thresh));

end
end


end
Expand Down Expand Up @@ -333,7 +337,7 @@ function ea_cvshowmatresultsCMTC(resultfig,directory,pV,pX,handles,options)
end
sX=ismember(round(pX),currentseed);
set(handles.matthreshis,'String',num2str(thresh));
matsurf=ea_showconnectivitypatch(resultfig,pV,mX,thresh);
matsurf=ea_showconnectivitypatch(resultfig,pV,mX,thresh,[],[],[],1,0);
seedsurf=ea_showseedpatch(resultfig,pV,sX,options);

setappdata(resultfig,'matsurf',matsurf);
Expand All @@ -351,8 +355,8 @@ function ea_cvshowmatresultsCMTC(resultfig,directory,pV,pX,handles,options)
cnt=1;

for pdir=1:length(pdirs)
[~,parcs{cnt}]=fileparts(pdirs(pdir).name);
cnt=cnt+1;
[~,parcs{cnt}]=fileparts(pdirs(pdir).name);
cnt=cnt+1;
end

set(handles.labelpopup,'String',parcs);
Expand Down Expand Up @@ -380,9 +384,9 @@ function ea_cvshowmatresultsCMTC(resultfig,directory,pV,pX,handles,options)
end

if ~ismember({selectedparc},parcs)

cv_enablevats(handles);
%
%
end


Expand Down Expand Up @@ -559,10 +563,10 @@ function ea_initvatlevel(handles,directory,selectedparc,options)
set(handles.rvatcheck,'Enable', ea_getonofftruefalse(ismember('vat_right.nii',vatcell)));
set(handles.lvatcheck,'Enable', ea_getonofftruefalse(ismember('vat_left.nii',vatcell)));
if strcmp(get(handles.rvatcheck,'Enable'),'off')
set(handles.rvatcheck,'Value', 0);
set(handles.rvatcheck,'Value', 0);
end
if strcmp(get(handles.lvatcheck,'Enable'),'off')
set(handles.lvatcheck,'Value', 0);
set(handles.lvatcheck,'Value', 0);
end
end

Expand Down Expand Up @@ -593,9 +597,9 @@ function ea_initvatlevel(handles,directory,selectedparc,options)
end
end
try delete(vatsurf); catch
for l=1:length(vatsurf)
try delete(vatsurf{l}); end
end
for l=1:length(vatsurf)
try delete(vatsurf{l}); end
end
end
try delete(seedsurf); end
try delete(graphsurf); end
Expand All @@ -608,7 +612,7 @@ function cv_enablevats(handles)
% set(handles.labelpopup,'Enable','on');
% set(handles.vizgraph,'Enable','off');
% set(handles.voxmodality,'Enable','off');
%
%
% set(handles.voxmetric,'Enable','off');
% set(handles.voxthresh,'Enable','off');
% set(handles.vizmat,'Enable','off');
Expand Down Expand Up @@ -1232,7 +1236,7 @@ function wmatmodality_Callback(hObject, eventdata, handles)
else
set(handles.chosenwmatstr,'String','');
end



% --- Executes during object creation, after setting all properties.
Expand Down Expand Up @@ -1266,3 +1270,61 @@ function wmatedges_Callback(hObject, eventdata, handles)

% Hint: get(hObject,'Value') returns toggle state of wmatedges
refreshcv(handles);


% --- Executes on button press in apply.
function apply_Callback(hObject, eventdata, handles)
% hObject handle to apply (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
refreshcv(handles,0,1);


% --- Executes on button press in vizvat_regs.
function vizvat_regs_Callback(hObject, eventdata, handles)
% hObject handle to vizvat_regs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of vizvat_regs
refreshcv(handles);


% --- Executes on button press in vizvat_labs.
function vizvat_labs_Callback(hObject, eventdata, handles)
% hObject handle to vizvat_labs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of vizvat_labs
refreshcv(handles);


% --- Executes on button press in vizmat_regs.
function vizmat_regs_Callback(hObject, eventdata, handles)
% hObject handle to vizmat_regs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of vizmat_regs
refreshcv(handles);


% --- Executes on button press in vizmat_labs.
function vizmat_labs_Callback(hObject, eventdata, handles)
% hObject handle to vizmat_labs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of vizmat_labs
refreshcv(handles);


% --- Executes on button press in wmatlabs.
function wmatlabs_Callback(hObject, eventdata, handles)
% hObject handle to wmatlabs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of wmatlabs
refreshcv(handles);
15 changes: 8 additions & 7 deletions connectomics/ea_cvshowfiberconnectivities.m
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,15 @@
%targets.img(targets.img<thresh)=0;



try
[PL.matsurf{side},PL.conlabels{side}]=ea_showconnectivitypatch(resultfig,targets,contargets,thresh,atlas_lgnd{2},tareas{side});
catch
keyboard
end
% always show seed patch (i.e. VAT)
PL.matseedsurf{side}=ea_showseedpatch(resultfig,seed{side},seed{side}.img,options);


if get(handles.vizvat_regs,'Value') || get(handles.vizvat_labs,'Value')
[PL.matsurf{side},PL.conlabels{side}]=ea_showconnectivitypatch(resultfig,targets,contargets,thresh,atlas_lgnd{2},tareas{side},[],get(handles.vizvat_regs,'Value'),get(handles.vizvat_labs,'Value'));
else
PL.matsurf{side}=[];
PL.conlabels{side}=[];
end
clear allcareas conareas
% %% now show areas
% targets.img=round(targets.img);
Expand Down
22 changes: 11 additions & 11 deletions connectomics/ea_cvshowvatdmri.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ function ea_cvshowvatdmri(resultfig,directory,handles,selectedparc,options)
fibersfile=vatmodality;

else
switch vatmodality
case 'Patient-specific fiber tracts'
fibersfile=[directory,options.prefs.FTR_normalized];
otherwise
fibersfile=[ea_getconnectomebase('dmri'),vatmodality,'.mat'];
end
switch vatmodality
case 'Patient-specific fiber tracts'
fibersfile=[directory,options.prefs.FTR_normalized];
otherwise
fibersfile=[ea_getconnectomebase('dmri'),vatmodality,'.mat'];
end
end

% seed filename
Expand All @@ -41,11 +41,11 @@ function ea_cvshowvatdmri(resultfig,directory,handles,selectedparc,options)
seedfile{v}=[directory,'stimulations',filesep,vsname,filesep,'vat_',usevat{options.sides(v)},'.nii'];
end
for side=1:length(usevat)
try
load([directory,'stimulations',filesep,vsname,filesep,'stimparameters_',usevat{options.sides(side)},'.mat']);
catch
keyboard
end
try
load([directory,'stimulations',filesep,vsname,filesep,'stimparameters_',usevat{options.sides(side)},'.mat']);
catch
keyboard
end
end

targetsfile=[options.earoot,'templates',filesep,'labeling',filesep,selectedparc,'.nii'];
Expand Down

0 comments on commit 3295130

Please sign in to comment.