Lead-DBS
  • Home
  • About
    • Deep Brain Stimulation
    • Quickstart Primer (Post-OP CT-Scans)
    • Quickstart Primer (Post-OP MR-Scans)
    • Publications
    • Citing Lead-DBS
    • Data & Code inclusion philosophy
    • List of Lead-DBS dependencies
    • Lead Connectome
  • News
  • Help/Support
    • Slack User Channel
    • Forum
    • Knowledge Base
      • Lead-DBS Methods
        • AC/PC to MNI conversion
        • DBS Network Mapping
        • Subcortical Electrophysiology Mapping (SEM)
      • Atlases/Resources
        • Cortical Atlas Parcellations (MNI-Space)
        • Subcortical Atlases (MNI-Space)
        • The DISTAL atlas
        • Macaque Atlases (MNI-Space)
        • Normative Connectomes
        • FEM-based VTA model
      • Walkthrough-Videos
      • Other Videos
      • Screenshots
  • Manual
  • Workshops
    • Brisbane February 2020
    • Machine Learning – Berlin September 2019
    • Berlin September 2019
    • Past workshops
      • Hamburg February 2019
      • Shanghai September 2018
      • Berlin 2016
  • Download
  • Contact
  • Search
  • Menu Menu

Localize DBS electrodes

You are here: Home1 / Forums2 / Support Forum (ARCHIVED – Please use Slack Channel instead)3 / Localize DBS electrodes4

Tagged: f

Viewing 15 posts - 16 through 30 (of 34 total)
← 1 2 3 →
  • Author
    Posts
  • 02/27/2017 at 9:55 PM #2153
    andreashorn
    Keymaster

    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 #2154
    Atefeh
    Participant

    Here 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 Horn

    if ischar(options) % return name of method.
    varargout{1}=’Advanced Normalization Tools (ANTs) SyN (Avants 2008)’;
    varargout{2}=1;
    return
    end

    usefa=1;
    usebrainmask=0;

    if ~exist(‘includeatlas’,’var’)
    includeatlas=0;
    end

    if ~includeatlas % second run from maget-brain segment
    ea_checkcoregallmri(options,usebrainmask)
    end

    directory=[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;
    end

    if 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;
    end

    ea_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
    end

    if ~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);
    end

    function 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);
    end

    function 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=”;
    end

    02/27/2017 at 10:43 PM #2155
    andreashorn
    Keymaster

    No 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 #2156
    Atefeh
    Participant

    I did it and now I get this:

    anatpresent =

    Empty cell array: 1-by-0

    02/27/2017 at 10:53 PM #2157
    andreashorn
    Keymaster

    Weird. 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 #2158
    Atefeh
    Participant

    I 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 #2159
    andreashorn
    Keymaster

    I 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 #2163
    Atefeh
    Participant

    Dear 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,
    Atefeh

    02/28/2017 at 12:11 AM #2165
    andreashorn
    Keymaster

    See 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 #2168
    andreashorn
    Keymaster

    Link was missing: github.com/leaddbs/leaddbs/releases

    03/02/2017 at 12:25 PM #2192
    Atefeh
    Participant

    Hi 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/uL9Bg

    As 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 6 years ago by Atefeh.
    03/11/2017 at 10:49 PM #2232
    Atefeh
    Participant

    Hello,
    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,
    Atefeh

    03/11/2017 at 11:14 PM #2233
    andreashorn
    Keymaster

    Hi 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 #2234
    Atefeh
    Participant

    Hi 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,
    Atefeh

    03/11/2017 at 11:32 PM #2235
    andreashorn
    Keymaster

    Hi 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

  • Author
    Posts
Viewing 15 posts - 16 through 30 (of 34 total)
← 1 2 3 →
  • The forum ‘Support Forum (ARCHIVED – Please use Slack Channel instead)’ is closed to new topics and replies.

Forum Statistics

Registered Users
130
Forums
1
Topics
185
Replies
607
Topic Tags
81

Subscribe to our newsletter

Latest Tweets

  • Tweet Avatar
    leaddbs
    @leaddbs
    RT @MichaelOkun: Congrats to @DBSThinkTank for the new Frontiers ebook of 26 articles and so far over 100,000 views.… https://t.co/BB5xZQsYr7

    1 year
  • Tweet Avatar
    leaddbs
    @leaddbs
    An automated programming algorithm building on top of Lead-DBS! 🎉😀🎈 https://t.co/2NxaVs9K9z

    1 year
  • Tweet Avatar
    leaddbs
    @leaddbs
    There will be a live demo of @leaddbs in Workshop #5! https://t.co/JCvSGZrkuH

    1 year

Recent Posts

  • Lead-OR out now
  • Bug in Lead-DBS v2.5
  • Lead-DBS v2.5 out now!
  • Lead-DBS on the cover of NeuroImage
  • Lead-DBS on the cover of Biological Psychiatry

Archives

  • August 2021
  • July 2021
  • March 2021
  • September 2020
  • June 2019
  • November 2018
  • September 2018
  • August 2018
  • March 2018
  • November 2017
  • September 2017
  • July 2017
  • April 2017
  • July 2016
  • June 2016
  • May 2016
  • March 2016
  • December 2015
  • November 2015
  • April 2015
  • January 2015
  • December 2014
  • October 2014
  • September 2014
  • July 2014
  • June 2014

Imprint | Privacy Policy

Scroll to top
We use cookies to ensure that we give you the best experience on our website. You may “Accept All” or visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
PHPSESSIDsessionThis cookie is native to PHP applications. The cookie is used to store and identify a users' unique session ID for the purpose of managing user session on the website. The cookie is a session cookies and is deleted when all the browser windows are closed.
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
CookieDurationDescription
_ga2 yearsThis cookie is installed by Google Analytics. The cookie is used to calculate visitor, session, campaign data and keep track of site usage for the site's analytics report. The cookies store information anonymously and assign a randomly generated number to identify unique visitors.
_gat_gtag_UA_52019623_11 minuteThis cookie is set by Google and is used to distinguish users.
_gid1 dayThis cookie is installed by Google Analytics. The cookie is used to store information of how visitors use a website and helps in creating an analytics report of how the website is doing. The data collected including the number visitors, the source where they have come from, and the pages visted in an anonymous form.
Third-party
Cookies from third-party contents on the website.
CookieDurationDescription
CONSENT16 years 5 months 17 days 13 hoursThese cookies are set via embedded youtube-videos. They register anonymous statistical data on for example how many times the video is displayed and what settings are used for playback.No sensitive data is collected unless you log in to your google account, in that case your choices are linked with your account, for example if you click “like” on a video.
IDE1 year 24 daysUsed by Google DoubleClick and stores information about how the user uses the website and any other advertisement before visiting the website. This is used to present users with ads that are relevant to them according to the user profile.
test_cookie15 minutesThis cookie is set by doubleclick.net. The purpose of the cookie is to determine if the user's browser supports cookies.
VISITOR_INFO1_LIVE5 months 27 daysThis cookie is set by Youtube. Used to track the information of the embedded YouTube videos on a website.
vuid2 yearsThis domain of this cookie is owned by Vimeo. This cookie is used by vimeo to collect tracking information. It sets a unique ID to embed videos to the website.
YSCsessionThis cookies is set by Youtube and is used to track the views of embedded videos.
yt-remote-connected-devicesneverNo description available.
yt-remote-device-idneverNo description available.
SAVE & ACCEPT
Powered by CookieYes Logo