From SyedQasim.Abbas at latrobe.edu.au Tue Jun 2 06:14:16 2020 From: SyedQasim.Abbas at latrobe.edu.au (Syed Qasim Abbas) Date: Tue, 2 Jun 2020 10:14:16 +0000 Subject: [Neuroimaging] nipype interface not working Message-ID: Hi, I am trying to use ANTS module available in nipype interface. The example code is given below: from nipype.interfaces.ants import CreateJacobianDeterminantImage >>> jacobian = CreateJacobianDeterminantImage() >>> jacobian.inputs.imageDimension = 3 >>> jacobian.inputs.deformationField = 'ants_Warp.nii.gz' >>> jacobian.inputs.outputImage = 'out_name.nii.gz' >>> jacobian.cmdline The problem is that the code is not generating the output image and runs without popping any error message. I am using spyder 4.1.3 to run this code. Thanks for your positive suggestions in response. Regards Qasim -------------- next part -------------- An HTML attachment was scrubbed... URL: From satra at mit.edu Tue Jun 2 08:09:33 2020 From: satra at mit.edu (Satrajit Ghosh) Date: Tue, 2 Jun 2020 08:09:33 -0400 Subject: [Neuroimaging] nipype interface not working In-Reply-To: References: Message-ID: hi qasim, the code is not running because the run function needs to be called jacobian.run(). i would recommend going through the nipype tutorials here: https://miykael.github.io/nipype_tutorial/ in the future, you can post questions like this to neurostars.org cheers, satra On Tue, Jun 2, 2020 at 6:14 AM Syed Qasim Abbas < SyedQasim.Abbas at latrobe.edu.au> wrote: > Hi, > > I am trying to use ANTS module available in nipype interface. The example > code is given below: > > > > *from* *nipype.interfaces.ants* *import* CreateJacobianDeterminantImage > > *>>> *jacobian = CreateJacobianDeterminantImage() > > *>>> *jacobian.inputs.imageDimension = 3 > > *>>> *jacobian.inputs.deformationField = 'ants_Warp.nii.gz' > > *>>> *jacobian.inputs.outputImage = 'out_name.nii.gz' > > *>>> *jacobian.cmdline > > > > The problem is that the code is not generating the output image and runs > without popping any error message. > > > > I am using spyder 4.1.3 to run this code. > > > > Thanks for your positive suggestions in response. > > > > Regards > > Qasim > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mattwint at iu.edu Tue Jun 2 14:51:44 2020 From: mattwint at iu.edu (Winter, Matthew) Date: Tue, 2 Jun 2020 18:51:44 +0000 Subject: [Neuroimaging] Nifti File Message-ID: <633a7e1584a942c380bd41c2d72c5c6b@BL-CCI-D2S02.ads.iu.edu> Hi, I am trying to do a time-frequency continuous wave transform on the Nifti files provided by the final pipeline in the Human Connectome Project?s MEG N-back task. I am working in MNE and trying to use their mne.time_frequency.tfr.cwt(). I have loaded the Nifti files into MNE, but am unaware of how to get the Nifti?s into the right format to be used by MNE functions that typically use .fif files. Is there a nibable function that could help with this process? Thank you for any advice. Best, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From SyedQasim.Abbas at latrobe.edu.au Tue Jun 2 18:06:24 2020 From: SyedQasim.Abbas at latrobe.edu.au (Syed Qasim Abbas) Date: Tue, 2 Jun 2020 22:06:24 +0000 Subject: [Neuroimaging] nipype interface not working In-Reply-To: References: Message-ID: Hi satra, Thanks for your prompt response. Cheers Regards Qasim From: Neuroimaging On Behalf Of Satrajit Ghosh Sent: Tuesday, 2 June 2020 10:10 PM To: Neuroimaging analysis in Python Subject: Re: [Neuroimaging] nipype interface not working hi qasim, the code is not running because the run function needs to be called jacobian.run(). i would recommend going through the nipype tutorials here: https://miykael.github.io/nipype_tutorial/ in the future, you can post questions like this to neurostars.org cheers, satra On Tue, Jun 2, 2020 at 6:14 AM Syed Qasim Abbas > wrote: Hi, I am trying to use ANTS module available in nipype interface. The example code is given below: from nipype.interfaces.ants import CreateJacobianDeterminantImage >>> jacobian = CreateJacobianDeterminantImage() >>> jacobian.inputs.imageDimension = 3 >>> jacobian.inputs.deformationField = 'ants_Warp.nii.gz' >>> jacobian.inputs.outputImage = 'out_name.nii.gz' >>> jacobian.cmdline The problem is that the code is not generating the output image and runs without popping any error message. I am using spyder 4.1.3 to run this code. Thanks for your positive suggestions in response. Regards Qasim _______________________________________________ Neuroimaging mailing list Neuroimaging at python.org https://mail.python.org/mailman/listinfo/neuroimaging -------------- next part -------------- An HTML attachment was scrubbed... URL: From larson.eric.d at gmail.com Wed Jun 3 16:55:48 2020 From: larson.eric.d at gmail.com (Eric Larson) Date: Wed, 3 Jun 2020 16:55:48 -0400 Subject: [Neuroimaging] Nifti File In-Reply-To: <633a7e1584a942c380bd41c2d72c5c6b@BL-CCI-D2S02.ads.iu.edu> References: <633a7e1584a942c380bd41c2d72c5c6b@BL-CCI-D2S02.ads.iu.edu> Message-ID: Looking at the docs for `cwt`: https://mne.tools/stable/generated/mne.time_frequency.tfr.cwt.html It just wants an `ndarray` of the right shape. `img.get_fdata()` in nibabel followed by `np.reshape` to get it to be 2D of shape (n_signals, n_times) and you should be good to go (and reshape back to the 4D image shape if you want). But this is going to be quite slow because there are so many signals, you're probably better off computing the CWT of the MEG sensor data, keeping it complex, then using linearity of the inverse to get it to source space (including an MRI image, if you want) then taking the magnitude, assuming you want that. Also, assuming that the MRI data are the *magnitude* (abs) of the response at the given voxel -- I haven't worked with HCP MRI images so I don't know -- doing the CWT of this is going to be problematic because of the nonlinearity of the magnitude operation... if on the other hand they are signed (e.g., the result of a max-power-ori LCMV or something) then doing it in source or sensor space (then projecting to source space) should be equivalent, but the former will be much slower than the latter. Eric On Tue, Jun 2, 2020 at 2:59 PM Winter, Matthew wrote: > Hi, > I am trying to do a time-frequency continuous wave transform on the Nifti > files provided by the final pipeline in the Human Connectome Project?s MEG > N-back task. I am working in MNE and trying to use their mne.time_frequency.tfr.cwt(). > I have loaded the Nifti files into MNE, but am unaware of how to get the > Nifti?s into the right format to be used by MNE functions that typically > use .fif files. Is there a nibable function that could help with this > process? Thank you for any advice. Best, Matt > > > > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jstadler at lin-magdeburg.de Tue Jun 2 06:23:42 2020 From: jstadler at lin-magdeburg.de (=?UTF-8?Q?J=c3=b6rg_Stadler?=) Date: Tue, 2 Jun 2020 12:23:42 +0200 Subject: [Neuroimaging] nipype interface not working In-Reply-To: References: Message-ID: Hi, this should only print the command line. jacobian.run() should do the trick. The example is misleading. J?rg > Hi, > > I am trying to use ANTS module available in nipype interface. The > example code is given below: > > ? > > *from**nipype.interfaces.ants**import*CreateJacobianDeterminantImage > > *>>> *jacobian =CreateJacobianDeterminantImage() > > *>>> *jacobian.inputs.imageDimension =3 > > *>>> *jacobian.inputs.deformationField ='ants_Warp.nii.gz' > > *>>> *jacobian.inputs.outputImage ='out_name.nii.gz' > > *>>> *jacobian.cmdline > > ? > > The problem is that the code is not generating the output image and > runs without popping any error message. > > ? > > I am using spyder 4.1.3 to run this code. > > ? > > Thanks for your positive suggestions in response. > > ? > > Regards > > Qasim > > > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging -------------- next part -------------- An HTML attachment was scrubbed... URL: From mattwint at iu.edu Thu Jun 4 15:16:34 2020 From: mattwint at iu.edu (Winter, Matthew) Date: Thu, 4 Jun 2020 19:16:34 +0000 Subject: [Neuroimaging] [External] Re: Nifti File In-Reply-To: References: <633a7e1584a942c380bd41c2d72c5c6b@BL-CCI-D2S02.ads.iu.edu>, Message-ID: <778f1670dc9c428aa52b2aedb90a471b@BL-CCI-D2S02.ads.iu.edu> Thanks so much Eric, that worked very well. From: Eric Larson Sent: Wednesday, June 3, 2020 4:56 PM To: Neuroimaging analysis in Python Subject: [External] Re: [Neuroimaging] Nifti File This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. Looking at the docs for `cwt`: https://mne.tools/stable/generated/mne.time_frequency.tfr.cwt.html It just wants an `ndarray` of the right shape. `img.get_fdata()` in nibabel followed by `np.reshape` to get it to be 2D of shape (n_signals, n_times) and you should be good to go (and reshape back to the 4D image shape if you want). But this is going to be quite slow because there are so many signals, you're probably better off computing the CWT of the MEG sensor data, keeping it complex, then using linearity of the inverse to get it to source space (including an MRI image, if you want) then taking the magnitude, assuming you want that. Also, assuming that the MRI data are the *magnitude* (abs) of the response at the given voxel -- I haven't worked with HCP MRI images so I don't know -- doing the CWT of this is going to be problematic because of the nonlinearity of the magnitude operation... if on the other hand they are signed (e.g., the result of a max-power-ori LCMV or something) then doing it in source or sensor space (then projecting to source space) should be equivalent, but the former will be much slower than the latter. Eric On Tue, Jun 2, 2020 at 2:59 PM Winter, Matthew > wrote: Hi, I am trying to do a time-frequency continuous wave transform on the Nifti files provided by the final pipeline in the Human Connectome Project's MEG N-back task. I am working in MNE and trying to use their mne.time_frequency.tfr.cwt(). I have loaded the Nifti files into MNE, but am unaware of how to get the Nifti's into the right format to be used by MNE functions that typically use .fif files. Is there a nibable function that could help with this process? Thank you for any advice. Best, Matt _______________________________________________ Neuroimaging mailing list Neuroimaging at python.org https://mail.python.org/mailman/listinfo/neuroimaging -------------- next part -------------- An HTML attachment was scrubbed... URL: From MKADWANI at mgh.harvard.edu Thu Jun 11 10:53:10 2020 From: MKADWANI at mgh.harvard.edu (Kadwani, Manorama) Date: Thu, 11 Jun 2020 14:53:10 +0000 Subject: [Neuroimaging] Problem with PySurfer module in Python3 Message-ID: Hi, I installed Pysurfer in a Ubuntu Linux environment according to the instructions on this page: http://pysurfer.github.io/install.html PySurfer Python Neuroimaging Visualization ? PySurfer 0.10.0 documentation Getting started?. Because PySurfer relies on some complicated dependencies (Mayavi, VTK and a GUI library), it can be more difficult to get started with than is the case with other Python libraries. pysurfer.github.io But Python3 gives me an error that this module was not found. Any ideas on what I missed? Thanks, Manorama Kadwani The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: From larson.eric.d at gmail.com Thu Jun 11 11:48:12 2020 From: larson.eric.d at gmail.com (Eric Larson) Date: Thu, 11 Jun 2020 11:48:12 -0400 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: Message-ID: > > But Python3 gives me an error that this module was not found. Any ideas on > what I missed? > On some systems you have to be careful about `python` vs `python3` and `pip` vs `pip3`. You might need to use `pip3`, or more explicitly perhaps `python3 -m pip` to run the command, i.e.: python3 -m pip install PySurfer You might currently hit a problem with Mayavi because they haven't released an update to deal with VTK9, in which case you might also need to do: python3 -m pip install vtk https://github.com/enthought/mayavi/archive/master.zip And then try the PySurfer line. Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From MKADWANI at mgh.harvard.edu Thu Jun 11 18:54:29 2020 From: MKADWANI at mgh.harvard.edu (Kadwani, Manorama) Date: Thu, 11 Jun 2020 22:54:29 +0000 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: , Message-ID: Hi Eric, I did take care of modifying the command and used 'python3 -m pip' instead of just 'pip'. Sorry I didn't specify that in my previous email. Ok, I installed VTK using that command, but it shows version 8.2.0 instead of 8.1.2 that came in the Mayavi-master package: mne: 0.20.0 numpy: 1.18.1 {blas=mkl_rt, lapack=mkl_rt} scipy: 1.4.1 matplotlib: 3.1.3 {backend=Qt5Agg} sklearn: 0.22.1 numba: 0.48.0 nibabel: 3.1.0 cupy: Not found pandas: 1.0.1 dipy: Not found mayavi: 4.7.1 {qt_api=pyqt5, PyQt5=5.9.2} pyvista: Not found vtk: 8.2.0 When I again tried installing PySurfer, it said that 'Requirement already satisfied: PySurfer in /usr/local/lib/python3.6/dist-packages'. Python3 still can't find PySurfer module. Also, I had installed VTK-9.0.0 previously using the configuration steps in https://vtk.org/Wiki/VTK/Building/Linux. There they mentioned configuring VTK with the path to the Qt build and path to VTK. Where is the location of VTK in that archive if I need to modify the cmakeList? Thanks, Manorama ________________________________ From: Neuroimaging on behalf of Eric Larson Sent: Thursday, June 11, 2020 11:48 AM To: Neuroimaging analysis in Python Subject: Re: [Neuroimaging] Problem with PySurfer module in Python3 External Email - Use Caution But Python3 gives me an error that this module was not found. Any ideas on what I missed? On some systems you have to be careful about `python` vs `python3` and `pip` vs `pip3`. You might need to use `pip3`, or more explicitly perhaps `python3 -m pip` to run the command, i.e.: python3 -m pip install PySurfer You might currently hit a problem with Mayavi because they haven't released an update to deal with VTK9, in which case you might also need to do: python3 -m pip install vtk https://github.com/enthought/mayavi/archive/master.zip And then try the PySurfer line. Eric The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: From larson.eric.d at gmail.com Fri Jun 12 12:13:57 2020 From: larson.eric.d at gmail.com (Eric Larson) Date: Fri, 12 Jun 2020 12:13:57 -0400 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: Message-ID: > > When I again tried installing PySurfer, it said that 'Requirement already > satisfied: PySurfer in /usr/local/lib/python3.6/dist-packages'. Python3 > still can't find PySurfer module. > You mean you do `import surfer` and get a `ModuleNotFoundError: No module named 'surfer'`? Also, you can try `python3 -m pip install --upgrade`, the message above indicates that it didn't bother to try installing the latest `PySurfer` because you already had one installed. > Also, I had installed VTK-9.0.0 previously using the configuration steps > in https://vtk.org/Wiki/VTK/Building/Linux. There they mentioned > configuring VTK with the path to the Qt build and path to VTK. Where is the > location of VTK in that archive if I need to modify the cmakeList? > VTK 8.2 (and even 8.1.2) should work okay for most systems. If you want to use VTK 9, please don't try to build it on your own (this will be difficult), first try installing the wheels. For some reason there are no Linux wheels on PyPi, but they are on the VTK website, so you can do: pip install --upgrade -f "https://vtk.org/download" "vtk>=9" Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From MKADWANI at mgh.harvard.edu Fri Jun 12 13:08:55 2020 From: MKADWANI at mgh.harvard.edu (Kadwani, Manorama) Date: Fri, 12 Jun 2020 17:08:55 +0000 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: , Message-ID: Yes, I meant that "import surfer" gave the ModuleNotFoundError. Thanks for the tip. I upgraded PySurfer. But the Ipython terminal still cannot find the surfer module. No, I didn't mean to use VTK 9 since you said that Mayavi can't deal with VTK9. What I meant was do I need to link that VTK8.2 (which is already present in the system) to Qt build or just installing it is enough? Similarly, does PySurfer need to be linked to these other packages or installing it should be enough to start using it? Thanks, Manorama ________________________________ From: Neuroimaging on behalf of Eric Larson Sent: Friday, June 12, 2020 12:13 PM To: Neuroimaging analysis in Python Subject: Re: [Neuroimaging] Problem with PySurfer module in Python3 External Email - Use Caution When I again tried installing PySurfer, it said that 'Requirement already satisfied: PySurfer in /usr/local/lib/python3.6/dist-packages'. Python3 still can't find PySurfer module. You mean you do `import surfer` and get a `ModuleNotFoundError: No module named 'surfer'`? Also, you can try `python3 -m pip install --upgrade`, the message above indicates that it didn't bother to try installing the latest `PySurfer` because you already had one installed. Also, I had installed VTK-9.0.0 previously using the configuration steps in https://vtk.org/Wiki/VTK/Building/Linux. There they mentioned configuring VTK with the path to the Qt build and path to VTK. Where is the location of VTK in that archive if I need to modify the cmakeList? VTK 8.2 (and even 8.1.2) should work okay for most systems. If you want to use VTK 9, please don't try to build it on your own (this will be difficult), first try installing the wheels. For some reason there are no Linux wheels on PyPi, but they are on the VTK website, so you can do: pip install --upgrade -f "https://vtk.org/download" "vtk>=9" Eric The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: From larson.eric.d at gmail.com Fri Jun 12 13:18:12 2020 From: larson.eric.d at gmail.com (Eric Larson) Date: Fri, 12 Jun 2020 13:18:12 -0400 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: Message-ID: > > Thanks for the tip. I upgraded PySurfer. But the Ipython terminal still > cannot find the surfer module. > if you do `which ipython` and `ipython --version` does it point to something like /usr/local/lib/python3.6/bin/ipython, or somewhere else? Do you have this problem when using plain `python3`? Can you `import surfer` there? If you `python3 -m pip install` and it works (i.e., no permissions error or anything), it should be able to find the module. No, I didn't mean to use VTK 9 since you said that Mayavi can't deal with > VTK9. What I meant was do I need to link that VTK8.2 (which is already > present in the system) to Qt build or just installing it is enough? > Similarly, does PySurfer need to be linked to these other packages or > installing it should be enough to start using it? > pip installing should be enough, no need to deal with linking to correct libraries (this should already be taken care of by by the VTK and Mayavi folks when packaging their modules in the wheels). Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From MKADWANI at mgh.harvard.edu Fri Jun 12 13:46:29 2020 From: MKADWANI at mgh.harvard.edu (Kadwani, Manorama) Date: Fri, 12 Jun 2020 17:46:29 +0000 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: , Message-ID: No, 'which ipython' points to /home/manoramak/anaconda3/bin/ipython. It works in plain python3! Thanks, Manorama ________________________________ From: Neuroimaging on behalf of Eric Larson Sent: Friday, June 12, 2020 1:18 PM To: Neuroimaging analysis in Python Subject: Re: [Neuroimaging] Problem with PySurfer module in Python3 External Email - Use Caution Thanks for the tip. I upgraded PySurfer. But the Ipython terminal still cannot find the surfer module. if you do `which ipython` and `ipython --version` does it point to something like /usr/local/lib/python3.6/bin/ipython, or somewhere else? Do you have this problem when using plain `python3`? Can you `import surfer` there? If you `python3 -m pip install` and it works (i.e., no permissions error or anything), it should be able to find the module. No, I didn't mean to use VTK 9 since you said that Mayavi can't deal with VTK9. What I meant was do I need to link that VTK8.2 (which is already present in the system) to Qt build or just installing it is enough? Similarly, does PySurfer need to be linked to these other packages or installing it should be enough to start using it? pip installing should be enough, no need to deal with linking to correct libraries (this should already be taken care of by by the VTK and Mayavi folks when packaging their modules in the wheels). Eric The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: From larson.eric.d at gmail.com Fri Jun 12 14:04:04 2020 From: larson.eric.d at gmail.com (Eric Larson) Date: Fri, 12 Jun 2020 14:04:04 -0400 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: Message-ID: So this is the problem, you have some paths mixed between two Python installations: ipython comes from anaconda and python3 comes from the system /usr/local. You should only use one or the other, and make sure that python/ipython/pip all point to the same Python installation otherwise you will have problems like this. If you want to use the system one, remove anaconda from your PATH / undo its setup steps, and use python3 / pip3 and make sure `ipython` points to something in the /usr/local/ directory. If you want to use anaconda, ensure that it's properly set up (and use `python` and `pip` directly, not `python3` / `pip3`). Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From MKADWANI at mgh.harvard.edu Mon Jun 15 14:55:14 2020 From: MKADWANI at mgh.harvard.edu (Kadwani, Manorama) Date: Mon, 15 Jun 2020 18:55:14 +0000 Subject: [Neuroimaging] Problem with PySurfer module in Python3 In-Reply-To: References: , Message-ID: Thanks for your help! Anaconda was installed properly, but I realized I was installing packages in the system's Python using pip, not conda's pip. I activated conda to be my base environment in every shell session and used conda's pip and so PySurfer could be imported. Manorama ________________________________ From: Neuroimaging on behalf of Eric Larson Sent: Friday, June 12, 2020 2:04 PM To: Neuroimaging analysis in Python Subject: Re: [Neuroimaging] Problem with PySurfer module in Python3 External Email - Use Caution So this is the problem, you have some paths mixed between two Python installations: ipython comes from anaconda and python3 comes from the system /usr/local. You should only use one or the other, and make sure that python/ipython/pip all point to the same Python installation otherwise you will have problems like this. If you want to use the system one, remove anaconda from your PATH / undo its setup steps, and use python3 / pip3 and make sure `ipython` points to something in the /usr/local/ directory. If you want to use anaconda, ensure that it's properly set up (and use `python` and `pip` directly, not `python3` / `pip3`). Eric The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: From seralouk at hotmail.com Tue Jun 16 05:13:24 2020 From: seralouk at hotmail.com (serafim loukas) Date: Tue, 16 Jun 2020 09:13:24 +0000 Subject: [Neuroimaging] Extracting the brain coordinates from a nifti volume Message-ID: <4E223C29-424B-42BD-8D2A-1AA082821214@hotmail.com> Hi Neuroimaging community, I have a single nifti (nii) file and I just want to extract the brain coordinates (in mm) for all voxels (i.e. the whole nii volume). How can I do that using nilearn/nibabel? Thank you From matthew.brett at gmail.com Tue Jun 16 10:39:43 2020 From: matthew.brett at gmail.com (Matthew Brett) Date: Tue, 16 Jun 2020 15:39:43 +0100 Subject: [Neuroimaging] Extracting the brain coordinates from a nifti volume In-Reply-To: <4E223C29-424B-42BD-8D2A-1AA082821214@hotmail.com> References: <4E223C29-424B-42BD-8D2A-1AA082821214@hotmail.com> Message-ID: Hi, On Tue, Jun 16, 2020 at 10:28 AM serafim loukas wrote: > > Hi Neuroimaging community, > > I have a single nifti (nii) file and I just want to extract the brain coordinates (in mm) for all voxels (i.e. the whole nii volume). > How can I do that using nilearn/nibabel? I think this will do what you want: [ins] In [1]: import numpy as np [ins] In [2]: import nibabel as nib [ins] In [3]: img = nib.load('my_image.nii') [ins] In [4]: vox_indices = np.indices(img.shape).transpose(1, 2, 3, 0) [ins] In [8]: mm = nib.affines.apply_affine(img.affine, vox_indices) Cheers, Matthew From seralouk at hotmail.com Tue Jun 16 12:42:46 2020 From: seralouk at hotmail.com (serafim loukas) Date: Tue, 16 Jun 2020 16:42:46 +0000 Subject: [Neuroimaging] Extracting the brain coordinates from a nifti volume In-Reply-To: References: <4E223C29-424B-42BD-8D2A-1AA082821214@hotmail.com> Message-ID: <9435DDA7-450C-4883-A0C2-05F3898A64E9@hotmail.com> Great? Thank you! Cheers, Makis > On 16 Jun 2020, at 16:39, Matthew Brett wrote: > > Hi, > > On Tue, Jun 16, 2020 at 10:28 AM serafim loukas wrote: >> >> Hi Neuroimaging community, >> >> I have a single nifti (nii) file and I just want to extract the brain coordinates (in mm) for all voxels (i.e. the whole nii volume). >> How can I do that using nilearn/nibabel? > > I think this will do what you want: > > [ins] In [1]: import numpy as np > [ins] In [2]: import nibabel as nib > [ins] In [3]: img = nib.load('my_image.nii') > [ins] In [4]: vox_indices = np.indices(img.shape).transpose(1, 2, 3, 0) > [ins] In [8]: mm = nib.affines.apply_affine(img.affine, vox_indices) > > Cheers, > > Matthew > _______________________________________________ > Neuroimaging mailing list > Neuroimaging at python.org > https://mail.python.org/mailman/listinfo/neuroimaging From shaitzvi at gmail.com Tue Jun 30 15:20:14 2020 From: shaitzvi at gmail.com (Shai Goldman) Date: Tue, 30 Jun 2020 15:20:14 -0400 Subject: [Neuroimaging] Creating a nibabel image using MNI coordinates help Message-ID: Dear Nipy team, I'm new to NiBabel/NiLearn and I'm trying to figure out how to plot some brain imaging based on MNI coordinates for ECoG data. I have a number of electrodes with x,y, and z coordinates in MNI space, and each electrode has a z-score value correlated with it. I found its easy to use plotting.view_markers(locations, marker_color=colors) with the locations of my electrodes and an array of colors based on my Z-scores and I get the electrodes plotted nicely into a 3d brain. I also have used plotting.plot_connectome(connections, locations, node_color=colors), with an empty connections matrix to achieve the same thing but in 2d. What I'm having a lot of trouble figuring out how to do, is to interpolate my electrode datapoints to the whole brain: i.e, instead of dots where the electrodes are, color the whole brain based on those dots. I figured I'd need to use something like plotting.plot_stat_map, but I cannot figure out how to create the image I am looking for which must be passed in. Is there an easy way to get an image of the standard MNI brain with the right affine and fdata based on the brains boundaries? What affine should be used for MNI? When I use plot_connectome or view_markers it does not ask me for any affines or data, so I'm confused as to how to properly build those matricies. Thanks, Shai -------------- next part -------------- An HTML attachment was scrubbed... URL: