How to save the eigen vector files

Dear All I am new to DIPY. I am using dipy's tensor fit command used by Marc Golub in his free water estimation using Beltrami fit code (as I have only six directional clinical scans). I would like to save the eigen vector files in nifti format which I would like to use for tractography using another software especially eigen vector 1. I followed the documentation given in webpage https://workshop.dipy.org/documentation/1.6.0./examples_built/reconst_dti/ and used the command save_nifti('tensor_evecs.nii.gz', tenfit.evecs.astype(np.float32), affine) but it looks like the above command saves the Diffusion tensor matrix Dxx, Dxy etc and is of 3*3 How to get only the eigenvector 1, 2 and 3 separately and save them separately I spent quite some time searching the DIPY documentation and email archives but was not able to find it. Can some in the email list kindly help me with the command to save the eigenvector 1 as a nifti file Thanks Venkat

Hi Venkateswaran, I think the command that you listed is indeed saving the eigenvectors. There are three eigenvectors and each has 3 components, hence 3x3 information at each voxel. They should be ordered with the principal eigenvector first, so just index your array at 0 in that dimension to get only the principal eigenvector. e.g. if your array is shape (H,W,D,3,3) then i believe you'd index with [:,:,:,0,:] Ebrahim On Mon, Sep 23, 2024 at 12:22 PM Venkateswaran Rajagopalan < venkateswaran@hyderabad.bits-pilani.ac.in> wrote:

Dear Ebrahim Thank you so much I will try saving it as suggested by you Venkateswaran On Tue, Sep 24, 2024 at 2:07 AM Ebrahim Ebrahim <ebrahim.ebrahim@kitware.com> wrote:
-- The information contained in this electronic communication is intended solely for the individual(s) or entity to which it is addressed. It may contain proprietary, confidential and/or legally privileged information. Any review, retransmission, dissemination, printing, copying or other use of, or taking any action in reliance on the contents of this information by person(s) or entities other than the intended recipient is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us by responding to this email or telephone and immediately and permanently delete all copies of this message and any attachments from your system(s). The contents of this message do not necessarily represent the views or policies of BITS Pilani.

Dear Ebrahim Thanks very much it worked one last help as I haven't used DIPY at all If I want to save the eigenvector 0 as an RGB nifti image i.e. combine the last dimension shown in bold (H,W,D,3,*3*) how to save it, will the following work for example tenfit = tenmodel.fit(maskdata) evec_0 =tenfit.evecs[:,:,:,0,:] nib.save(nib.Nifti1Image(np.array(255 * evec_0, 'uint8'), img.affine), 'evec0_rgb.nii.gz') Thanks a lot Venkateswaran On Tue, Sep 24, 2024 at 8:40 AM Venkateswaran Rajagopalan < venkateswaran@hyderabad.bits-pilani.ac.in> wrote:
-- The information contained in this electronic communication is intended solely for the individual(s) or entity to which it is addressed. It may contain proprietary, confidential and/or legally privileged information. Any review, retransmission, dissemination, printing, copying or other use of, or taking any action in reliance on the contents of this information by person(s) or entities other than the intended recipient is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us by responding to this email or telephone and immediately and permanently delete all copies of this message and any attachments from your system(s). The contents of this message do not necessarily represent the views or policies of BITS Pilani.

Hi Venkateswaran, I think the command that you listed is indeed saving the eigenvectors. There are three eigenvectors and each has 3 components, hence 3x3 information at each voxel. They should be ordered with the principal eigenvector first, so just index your array at 0 in that dimension to get only the principal eigenvector. e.g. if your array is shape (H,W,D,3,3) then i believe you'd index with [:,:,:,0,:] Ebrahim On Mon, Sep 23, 2024 at 12:22 PM Venkateswaran Rajagopalan < venkateswaran@hyderabad.bits-pilani.ac.in> wrote:

Dear Ebrahim Thank you so much I will try saving it as suggested by you Venkateswaran On Tue, Sep 24, 2024 at 2:07 AM Ebrahim Ebrahim <ebrahim.ebrahim@kitware.com> wrote:
-- The information contained in this electronic communication is intended solely for the individual(s) or entity to which it is addressed. It may contain proprietary, confidential and/or legally privileged information. Any review, retransmission, dissemination, printing, copying or other use of, or taking any action in reliance on the contents of this information by person(s) or entities other than the intended recipient is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us by responding to this email or telephone and immediately and permanently delete all copies of this message and any attachments from your system(s). The contents of this message do not necessarily represent the views or policies of BITS Pilani.

Dear Ebrahim Thanks very much it worked one last help as I haven't used DIPY at all If I want to save the eigenvector 0 as an RGB nifti image i.e. combine the last dimension shown in bold (H,W,D,3,*3*) how to save it, will the following work for example tenfit = tenmodel.fit(maskdata) evec_0 =tenfit.evecs[:,:,:,0,:] nib.save(nib.Nifti1Image(np.array(255 * evec_0, 'uint8'), img.affine), 'evec0_rgb.nii.gz') Thanks a lot Venkateswaran On Tue, Sep 24, 2024 at 8:40 AM Venkateswaran Rajagopalan < venkateswaran@hyderabad.bits-pilani.ac.in> wrote:
-- The information contained in this electronic communication is intended solely for the individual(s) or entity to which it is addressed. It may contain proprietary, confidential and/or legally privileged information. Any review, retransmission, dissemination, printing, copying or other use of, or taking any action in reliance on the contents of this information by person(s) or entities other than the intended recipient is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us by responding to this email or telephone and immediately and permanently delete all copies of this message and any attachments from your system(s). The contents of this message do not necessarily represent the views or policies of BITS Pilani.
participants (2)
-
Ebrahim Ebrahim
-
Venkateswaran Rajagopalan