Tagged: f
-
AuthorPosts
-
02/27/2017 at 9:55 PM #2153andreashornKeymaster
Okay, thanks! Can you please set a breakpoint after line 56 in ea_normalize_ants and tell me how the variable “anatpresent” is defined? It should be a cellstring with a single entry {‘anat_t2.nii’}.
02/27/2017 at 10:27 PM #2154AtefehParticipantHere I copied the ea_normalize_ants file:
function varargout=ea_normalize_ants(options,includeatlas)
% This is a function that normalizes both a copy of transversal and coronar
% images into MNI-space. The goal was to make the procedure both robust and
% automatic, but still, it must be said that normalization results should
% be taken with much care because all reconstruction results heavily depend
% on these results. Normalization of DBS-MR-images is especially
% problematic since usually, the field of view doesn’t cover the whole
% brain (to reduce SAR-levels during acquisition) and since electrode
% artifacts can impair the normalization process. Therefore, normalization
% might be best archieved with other tools that have specialized on
% normalization of such image data.
%
% The procedure used here uses the ANTs Syn approach to map a patient’s
% brain to MNI space directly.
% __________________________________________________________________________________
% Copyright (C) 2015 Charite University Medicine Berlin, Movement Disorders Unit
% Andreas Hornif ischar(options) % return name of method.
varargout{1}=’Advanced Normalization Tools (ANTs) SyN (Avants 2008)’;
varargout{2}=1;
return
endusefa=1;
usebrainmask=0;if ~exist(‘includeatlas’,’var’)
includeatlas=0;
endif ~includeatlas % second run from maget-brain segment
ea_checkcoregallmri(options,usebrainmask)
enddirectory=[options.root,options.patientname,filesep];
cnt=1;
if usebrainmask
bprfx=’b’;
else
bprfx=”;
end
spacedef=ea_getspacedef; % get definition of current space we are working in
if usefa && spacedef.hasfa % first put in FA since least important (if both an FA template and an fa2anat file is available)
if exist([directory,options.prefs.fa2anat],’file’) % recheck if now is present.
disp(‘Including FA information for white-matter normalization.’);
to{cnt}=[ea_space(options),’fa.nii’];
from{cnt}=[directory,bprfx,options.prefs.fa2anat];
weights(cnt)=0.5;
metrics{cnt}=’MI’;
cnt=cnt+1;
end
end[~,anatpresent]=ea_assignpretra(options);
anatpresent=flip(anatpresent); % reverse order since most important transform should be put in last.
% The convergence criterion for the multivariate scenario is a slave to the last metric you pass on the ANTs command line.
for anatf=1:length(anatpresent)
disp([‘Including ‘,anatpresent{anatf},’ data for (grey-matter) normalization’]);to{cnt}=[ea_space(options),ea_det_to(anatpresent{anatf},spacedef),’.nii’];
if usebrainmask && (~includeatlas) % if includeatlas is set we can assume that images have been coregistered and skulstripped already
ea_maskimg(options,[directory,anatpresent{anatf}],bprfx);
end
from{cnt}=[directory,bprfx,anatpresent{anatf}];
weights(cnt)=1.25;
metrics{cnt}=’MI’;
cnt=cnt+1;
endif includeatlas % append as last to make criterion converge on this one.
to{cnt}=[ea_space(options),’atlas.nii’];
from{cnt}=[directory,’anat_atlas.nii.gz’];
weights(cnt)=1.5;
metrics{cnt}=’MI’; % could think about changing this to CC
cnt=cnt+1;
endea_ants_nonlinear(to,from,[directory,options.prefs.gprenii],weights,metrics,options);
ea_apply_normalization(options);function masks=segmentall(from,options)
directory=[fileparts(from{1}),filesep];
for fr=1:length(from)
[~,fn,ext]=fileparts(from{fr});
switch [fn,ext]
case options.prefs.fa2anat
if ~exist([directory,’tc2′,options.prefs.prenii_unnormalized],’file’)
ea_newseg(directory,options.prefs.prenii_unnormalized,0,options);
% assume that tc2 doesn’t exist
nii=ea_load_nii([directory,’c2′,options.prefs.prenii_unnormalized]);
nii.img=nii.img>0.7;
nii.fname=[directory,’tc2′,options.prefs.prenii_unnormalized];
spm_write_vol(nii,nii.img);
end
masks{fr,1}=[ea_space(options),’c2mask.nii’];
masks{fr,2}=[directory,’tc2′,options.prefs.prenii_unnormalized];otherwise
if ~exist([directory,’tc1′,options.prefs.prenii_unnormalized],’file’)
ea_newseg(directory,options.prefs.prenii_unnormalized,0,options);
% assume that tc1 doesn’t exist
nii=ea_load_nii([directory,’c1′,options.prefs.prenii_unnormalized]);
nii.img=nii.img>0.3;
nii.fname=[directory,’tc1′,options.prefs.prenii_unnormalized];
spm_write_vol(nii,nii.img);
end
masks{fr,1}=[ea_space(options),’c1mask.nii’];
masks{fr,2}=[directory,’tc1′,options.prefs.prenii_unnormalized];
end
endif ~exist([directory,’tc1c2′,options.prefs.prenii_unnormalized],’file’)
Vc1=ea_load_nii([directory,’tc1′,options.prefs.prenii_unnormalized]);
Vc2=ea_load_nii([directory,’tc2′,options.prefs.prenii_unnormalized]);
Vc1.img=Vc1.img+Vc2.img;
Vc1.fname=[directory,’tc1c2′,options.prefs.prenii_unnormalized];
spm_write_vol(Vc1,Vc1.img);
endfunction ea_genbrainmask(options)
directory=[options.root,options.patientname,filesep];
ea_newseg(directory,options.prefs.prenii_unnormalized,0,options);
c1=ea_load_nii([directory,’c1′,options.prefs.prenii_unnormalized]);
c2=ea_load_nii([directory,’c2′,options.prefs.prenii_unnormalized]);
c3=ea_load_nii([directory,’c3′,options.prefs.prenii_unnormalized]);
bm=c1;
bm.img=c1.img+c2.img+c3.img;
bm.fname=[directory,’brainmask.nii’];
bm.img=bm.img>0.6;
spm_write_vol(bm,bm.img);function ea_maskimg(options,file,prefix)
directory=[options.root,options.patientname,filesep];
if ~exist([directory,’brainmask.nii’],’file’)
ea_genbrainmask(options);
end
[pth,fn,ext]=fileparts(file);
if ~exist([pth,filesep,prefix,fn,ext],’file’)
nii=ea_load_nii(file);
bm=ea_load_nii([directory,’brainmask.nii’]);
nii.img=nii.img.*double(bm.img);
nii.fname=[pth,filesep,prefix,fn,ext];
spm_write_vol(nii,nii.img);
endfunction template2use=ea_det_to(anatfile,spacedef)
anatfile=strrep(anatfile,’anat_’,”);
anatfile=strrep(anatfile,’.nii’,”);for avtpl=1:length(spacedef.templates)
if ismember(anatfile,spacedef.norm_mapping{avtpl})
template2use=spacedef.templates{avtpl};
return
end
end
% template still hasn’t been assigned, use misfit template if not empty:
if ~isempty(spacedef.misfit_template)
template2use=spacedef.misfit_template;
else
template2use=”;
end02/27/2017 at 10:43 PM #2155andreashornKeymasterNo I meant to add a breakpoint. For instance you can write the word “keyboard” on that line, save the file and try normalization again. Then Matlab will stop at that particular line, showing you a K> symbol in the command prompt.
Then enter “anatpresent” there and let me know what it says.Btw just tried to reproduce the error here but works fine on my side.
Best, Andy
02/27/2017 at 10:50 PM #2156AtefehParticipantI did it and now I get this:
anatpresent =
Empty cell array: 1-by-0
02/27/2017 at 10:53 PM #2157andreashornKeymasterWeird. Can you delete (or move somewhere) the file in your home folder called .ea_prefs.m?
Then restart lead and try again?02/27/2017 at 10:57 PM #2158AtefehParticipantI get this:
Undefined function ‘ea_prefs’ for input arguments of type ‘char’.
Error in ea_checkleaddirs (line 2)
prefs=ea_prefs(”);Error in lead>lead_OpeningFcn (line 72)
ea_checkleaddirs;Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});Error in lead (line 42)
gui_mainfcn(gui_State, varargin{:});02/27/2017 at 11:01 PM #2159andreashornKeymasterI think now you deleted the ea_prefs.m inside the Lead-DBS folder. I meant a hidden file called .ea_prefs.m (starting with a dot) in your Windows home directory.
02/28/2017 at 12:02 AM #2163AtefehParticipantDear Andy,
Is it possible that I ask you to send me a version which was available on the website before 10.Feb?
After that I updated the lead dbs and it did not work anymore…Best,
Atefeh02/28/2017 at 12:11 AM #2165andreashornKeymasterSee here:
I don’t have any ready-made .zip files from before but you can get the code from any release there on github.
However, I’m pretty sure that this is not the reason. We and other labs use Lead-DBS a lot on a daily basis and we don’t get this error. I would have definitely heard of this error if it had to do with the current release.Rather than going back I’d even recommend going forward by installing via github (see ) and you’d get the newest features and we can much easier fix small issues that may occur.
Also, would really recommend to do a complete clean install, i.e. deleting all Lead-DBS related code (including the .ea_prefs.m file in your windows user home) and then installing freshly either from website or via Github.
Best, Andy
02/28/2017 at 12:12 AM #2168andreashornKeymasterLink was missing: github.com/leaddbs/leaddbs/releases
03/02/2017 at 12:25 PM #2192AtefehParticipantHi Andy,
I installed lead DBS again and it is working well now. Thanks for you help.
I have a question this time. I have uploaded 2 images:image 1: http://imgur.com/a/qqp8m
image 2: http://imgur.com/a/uL9BgAs I did the electrode localization previously, I got image1, but now I get image2 (with less setting options). Why is it like that?
Kind regards,
Atefeh- This reply was modified 7 years, 9 months ago by Atefeh.
03/11/2017 at 10:49 PM #2232AtefehParticipantHello,
I have imported MRI of different patients to lead DBS for localization of the STN subdivisions. All the images look completely the same!!! Only the location of the STN is different.I am not sure if lead DBS is working correctly.
Any kind of help is appreciated.
Regards,
Atefeh03/11/2017 at 11:14 PM #2233andreashornKeymasterHi Atefeh,
thank you for your message – however it’s a bit hard to find out what (you think) went wrong.
There are so many ways to use Lead-DBS to analyze your data and it is very important that you understand what it actually does to interpret results. For us to help you / explain what’s happening, it’s is similarly important that you let us know what you exactly did.Some basics that might help:
1. Lead-DBS uses atlases to define anatomy. There is no option to subdivide the STN in single patients (although we’re losely working on such things).
2. It is a big difference whether you visualize results in native or template space. In the first option, the atlas is co-registered into native space, in the second case the MRI data of the patient is co-registered into template space (where the atlas is defined).
3. These warps (from native to template and back) are performed using the best nonlinear methods available in the field (e.g. see Klein 2009 NeuroImage) that have been specially tuned to be precise in the subcortex. Still, as in any scientific model, the model has limitations.
4. These limitations are largely driven by the quality of your preoperative imaging data and quality. For instance you can supply 10 different MRI sequences including some special Basal ganglia sequences (FGATIR, QSM etc) of the same patient to Lead-DBS and use *all of them* simultaneously to define the warp e.g. using the Unified Segmentation approach by John Ashburner on a specialized tissue prior model featuring regions of interest (STN, GPi) included in Lead-DBS. If you did that, I’d guess that the nonlinear transform would be really accurate, really showing a precise location of electrodes in relationship to the atlas STN. However, this is an ideal scenario and most Universities don’t have such great preoperative imaging protocols. Rather, in a “standard use case”, most centers have a T1 sequence and a T2 sequence or similar. Often in poor resolution. If you supply this data to Lead-DBS, it will still give you a result but the accuracy is just way worse than in the first case. So part of getting good results are not dependent on the *data* and not the methods of Lead-DBS.
5. A good rule of thumb to find out how precise results could optimally be is for instance whether you can clearly discern the structures of interest on the preoperative acquisition. Say, you cannot clearly see the STN yourself on an image, you’re not totally sure where it starts and where it ends. In such a case, Lead-DBS will not be able to apply some magic and still see the structure, let alone the STN subdivisions. It will make a “best guess” based on surrounding anatomy and the segmentation results but that’s all you can get with poor data.
6. Finally, please be aware that none of the segmentation/normalization techniques have been developed by ourselves. We use freely available tools and sometimes tweak them a bit for subcortical anatomy. All these methods are published and well documented. It is highly recommended to study how these methods work, what their benefits are and their limitations.Now getting maybe a bit closer to your problem: You described “all images looked the same”. If you mean the visualization of anatomy in the 3D viewer, it could have been that the MNI template was displayed instead of patient specific anatomy? This is the default setting. You can visualize patient anatomy by choosing what to display in the anatomy slices panel. Maybe this helps?
Best, Andy
03/11/2017 at 11:28 PM #2234AtefehParticipantHi Andy,
Many thanks for your explanation.
1. Yes! I think it is a template that is displaying everytime, but I dont know how to change the settings in order to display the specific patients anatomy…
2.If you look at my message at 03.02.2017, I have uploaded to images from anatomy slice panel. I did not get any answers from you for that question.
Best,
Atefeh03/11/2017 at 11:32 PM #2235andreashornKeymasterHi Atefeh,
it’s true we stripped some options from the anatomy panel but these were not really working before, anyways.
Mainly, these options were meant to export 2D slices into the 3D viewer. We decided to rather make similar functionality available via the 2D export (from the Lead main gui) or in Lead anatomy.You can use the popup menu shown in your screenshots to visualize patient anatomy instead of the MNI template.
Best
-
AuthorPosts
- The forum ‘Support Forum (ARCHIVED – Please use Slack Channel instead)’ is closed to new topics and replies.