Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Nov 29 03:55
    ShreyasFadnavis commented #2682
  • Nov 28 04:29
    LaraFernandez44 commented #2682
  • Nov 28 04:20
    skoudoro labeled #2682
  • Nov 28 04:17
    skoudoro commented #2682
  • Nov 28 04:04
    LaraFernandez44 opened #2682
  • Nov 18 16:45
    skoudoro closed #2679
  • Nov 18 16:45
    skoudoro commented #2679
  • Nov 18 16:01
    ggomezji opened #2679
  • Nov 16 20:17
    drombas commented #2425
  • Nov 16 13:56
    iPsych commented #2425
  • Nov 14 12:37
    samuelstjean commented #2666
  • Nov 14 12:26
    samcoveney commented #2666
  • Nov 14 12:23
    samcoveney commented #2666
  • Nov 14 12:21
    samcoveney commented #2666
  • Nov 10 15:49
    skoudoro closed #2676
  • Nov 10 15:49
    skoudoro locked #2676
  • Nov 10 15:49
    skoudoro commented #2676
  • Nov 10 14:10
    DelinteNicolas opened #2676
  • Nov 09 06:15
    pjsjongsung commented #2626
  • Nov 09 06:10
    codecov[bot] commented #2626
Serge Koudoro

Hello @/all ,

Dr. Leevi Kerkelä (UCL) will discuss today (Thursday 15 April at 1pm EST / 7pm CET / 10am PT) his project on integrating Q-Space Trajectory Imaging in DIPY.

The zoom link for the open meeting is https://iu.zoom.us/j/84926066336.

We hope to see you online!

Cheers !

Chandana Kodiweera
Hi All, are you aware of a software that can do automated DWI QC? We are looking for something to bypass visual inspection as it's a very large dataset. Thank you!
Conor Owens-Walton

Hi DIPY team. Wanted to ask about a memory error I am getting when running dipy_track on a linux server.

File "~/cowenswalton/conda-envs/envs/buan_env/lib/python3.8/site-packages/dipy/tracking/utils.py", line 881, in transform_tracking_output yield np.dot(sl, lin_T) + offset MemoryError
Super grateful for any advice, or where i can find some.

Conor Owens-Walton
OK I am trying to run dipy_track again on our grid but requesting a bit more memory. Hopefully this works out.
Ariel Rokem
@ShreyasFadnavis : what do you think about running patch2self on data that has already been denoised using another method (mp-pca in this case)?
Shreyas Fadnavis
@arokem That is a great question! It is definitely possible and should work. MPPCA for instance is doing a local low-rank approximation which does not change the assumption that Patch2Self relies on. In fact, P2S can also be applied to data that has undergone other types of pre-processing such as Eddy, Motion, Susceptibility, etc. As long as the pre-processing step applied does not start adding correlation artefacts across volumes, Patch2Self can be applied after!
Also from a denoising standpoint, Patch2Self (standalone) should do as good as Patch2Self + MPPCA. Any noise that persists due to MPPCA will anyways be suppressed by P2S.
Ariel Rokem
Thanks @ShreyasFadnavis!
Hello all,
Does anyone have experience tracking using DSI reconstructed data? I have a dataset of 145x174x145, so I can't fit all the data since that uses too much RAM. I tried using a memmap, but this still needs too much memory (134 GB).
I can construct the model and fit the data to the model using nindex and saving to a memmap, but using that memmap in e.g. the ClosestPeakDirectionGetter causes a memory error. Does anyone know a solution to this? Thank you very much in advance!
Hi all,
I have a theoretical question about DKI minimum number of independent directions. Indeed, we are acquiring neonatal SC diffusion images at hospital but we are limited by acquisition time constraints: the clinical protocol is already quite long and we have to put the spine DKI sequence at the end since it is for research. We set up a protocol made up of 6b=0; 13 b=700; 13 b=2100 b values for a duration of 4 min 30 s thanks to multi band technique. I know it is low as a protocol for DKI but I tried increasing directions to 15 (minimum theoretically required for DKT estimation) and it lasts 1 minute more , and it often happens the neonate wakes up from the slight sedation just during the end of that sequence, so the clinicians opted for the 13-direction sequence.
Now, I am here to ask you a suggestion about which choice to take. I have read about protocol using just 9 directions per b-value for fast DKI protocol. If I use 13 directions, would DKI measures I compute in dipy be still reliable ? Or should I use another estimation method in case of so low directions ?
thank you very much in advance
Matt Cieslak
Hi @Gemmavdv I've been using DSI for a long time, have you tried DSI Studio?
Ariel Rokem
@rosella1234 : theoretically, I believe that this should be enough to estimate DKI. I would recommend using the msdki method, which should be generally more robust to low SNR situations https://dipy.org/documentation/1.0.0./examples_built/reconst_msdki/
Eleftherios Garyfallidis
@Gemmavdv something is unexpected. There should be no issues in tracking with DSI data. But can you explain more what you do here? Also the shape of the data is 3D but your data should be 4D.
@arokem thank you! so do you suggest extracting just MSDKI as a DKI metric, and not the standard ones (MK;AK;RK;KFA..)?
Thank you @mattcieslak and @Garyfallidis . I solved the problem, I didn't actually need to use memmaps. Sorry to waste your time!
Serge Koudoro

Hello @/all ,

Quick reminder for the meeting today at 1pm EST / 7pm CET / 10am PT!

@gabknight will talk about the new Tractography competition.
We will have a brief talk about our Tracking framework
@skoudoro will make a quick overview of the future Release. Let us know if there is any request.

ps: same link as usual: https://iu.zoom.us/j/84926066336

Steven Meisler
I am trying to run Recobundles on an MrTrix tractogram (.tck) using only command line tools. I am able to use SLR to get it to MNI space as a .trk. Then I segment that into bundles (recobundles), but when I try to move it back to native space (labelbundles) I get an error since my original tck file does not have a proper header like a trk file. Is there a way to include a reference image in the labelbundles command line function? If so, should I use the diffusion image, t1 image, or something else? Thanks.
Bramsh Q Chandio

Hi @smeisler
Currently, dipy_labelsbundles does not take reference files as input. However, you can write a simple python script to bring bundles into the native space. Here's the bundle segmentation tutorial https://dipy.org/documentation/1.4.0./examples_built/bundle_extraction/#example-bundle-extraction
at the end of this tutorial after extracting the bundle, we are saving the bundle in the native space. Something like this:

 `reco_af_l = StatefulTractogram(target[af_l_labels], target_header,
                           Space.RASMM)     `
 `save_trk(reco_af_l, "AF_L.trk", bbox_valid_check=False)     `

You can use the labels.npy file saved by RecoBundles command line.

Steven Meisler
@BramshQamar got it, thanks! Ended up using a nibabel implementation https://github.com/nipy/nibabel/blob/master/nibabel/cmdline/tck2trk.py

When trying to apply cross-validation for dki model on 7T adult HCP data the following error arises:

base) synapsi@charlie:/media/synapsi/dkeTest/new_version/code$ python goodness_of_fit.py
/home/synapsi/anaconda3/lib/python3.8/site-packages/dipy/core/gradients.py:295: UserWarning: b0_threshold (value: 50) is too low, increase your b0_threshold. It should be higher than the lowest b0 value (55.0).
warn("b0_threshold (value: {0}) is too low, increase your \
Data & Mask Loaded!
Traceback (most recent call last):
File "goodness_of_fit.py", line 21, in <module>
dki_cc = xval.kfold_xval(dki_model, cc_vox, 2)
File "/home/synapsi/anaconda3/lib/python3.8/site-packages/dipy/reconst/cross_validation.py", line 107, in kfold_xval
raise ValueError(msg)
ValueError: np.mod(143, 2) is 1

Hi all, is there a way to visualize Diffusion Kurtosis Tensor 3D geometry in a single voxel in dipy? thank you
Hi, I sent this question as a mail but it bounced. Does anyone know how to do this? Thanks!

I'm computing affine transforms for co-registering anatomical MRI scans.

Sometimes I would like to re-use those transforms, so in a case similar to the example here

my final transform is the result of this command:
rigid = affreg.optimize ( static, moving, transform, params0,
static_affine, moving_affine,
starting_affine = translation.affine );
final = rigid;
after first having aligned the centres of gravity.

After this command I can call
resampled = final.transform ( moving );
and then I get the desired result.

What I don't understand is how to store the transform and re-use it later.
I have tried to just save the object 'final' with
np.savez ( 'transformation.npz', final );
and then load it later with
with np.load ( 'transformation.npz', allow_pickle = True ) as npzfile:
final = npzfile [ 'arr_0' ];
and then re-run
resampled = final.transform ( moving );
but that returns the following error:
resampled = final.transform ( moving );
AttributeError: 'numpy.ndarray' object has no attribute 'transform'

So what I understand from this is that the output 'rigid' from the affreg.optimize() command has an attribute
'transform', but when I save it and then load it again it does not any more.

Is there a(nother) way to save and (re)load transforms?


Hi, all. I have some problems when fit the free water components. Does anyone know how to fix this? Thanks a lot!

I having using the fwdtimodel and fwdtifit to map the free water compartment.

The test data is download from HCP, with 288 directions and 2 b-values:
The code is as follows:
fwdtimodel = fwdti.FreeWaterTensorModel(gtab)
fwdtifit = fwdtimodel.fit(data, mask=mask)
fwvolume = fwdtifit.f

But there are some warning information:
/usr/local/lib64/python3.6/site-packages/scipy/optimize/minpack.py:475: RuntimeWarning: Number of calls to function has reached maxfev = 1800.
warnings.warn(errors[info][0], RuntimeWarning)
/usr/local/lib64/python3.6/site-packages/dipy/reconst/fwdti.py:311: RuntimeWarning: overflow encountered in exp
SIpred = (1-FS)np.exp(np.dot(W, all_new_params)) + FSS0*SFW.T

/usr/local/lib64/python3.6/site-packages/dipy/reconst/fwdti.py:312: RuntimeWarning: overflow encountered in square
F2 = np.sum(np.square(SI - SIpred), axis=0)

/usr/local/lib64/python3.6/site-packages/dipy/reconst/fwdti.py:458: RuntimeWarning: overflow encountered in exp
y = (1-f) * np.exp(np.dot(design_matrix, tensor[:7])) + \

I wonder whether these warnings have influenced the output images and anyway to fix them?

Many thanks for your help!

David Romero-Bascones
Hi @amwink

To save/load the transformation object you can try using pickle instead of numpy:
import pickle
filehandler = open('transform.obj', 'wb')
pickle.dump(final, filehandler)

filehandler = open('transform.obj', 'rb')
final = pickle.load(filehandler)


Hi @drombas, thanks very much! pickle does the trick :)

I thought that np.save with "allow pickle" would work, assuming that it would do the same as pickle (it doesn't) or that using JSON would be possible -- unfortunately it isn't (I tried to do the nested serialisation but failed). The reason for that is that many people have reservations about pickle.

For me it does the job perfectly.

Serge Koudoro
Also, @amwink, you can look at the functions write_mapping and read_mapping in https://github.com/dipy/dipy/blob/master/dipy/align/_public.py#L218
from dipy.align import write_mapping, read_mapping we use the nifti format to save this
Thanks @skoudoro ! I guess you can save the results of a rigid or affine registration as a mapping (though it would be a bit of overkill to store them in 3 3D images when 6 or 16 floats would do :). The versions of read_mapping and write_mapping for rigid and affine transforms would just need to store 3 translations + 3 rotations or a homogeneous coordinate transformation, respectively?
Hi, is DBSI fitting available in dipy? and, if not, are there any plans to include it? Thanks!
Dear all, I want to calculate the volume of a fiber bundle in each hemisphere apart, is it possible to do that in DIPY? If yes how can I do it ?
I will appreciate any help, and any ideas.
Thank you very much.
Priscilla Galinié
Hello everyone! I am currently trying to use dipy to process DTI data, I would like to do fiber tracking. Because it is DTI data and not HARDI data, I want to use the FACT method. I read in previous messages that I can use LocalTracking(..., fixedstep = False) and then provide the DTI directions as a direction getter. And there is my issue... I tried using tenfit.directions or even tenfit.evecs but it doesn't work. Maybe it is simple but I have been looking for a while and I don't find a solution.
I would really appreciate your help, thank you in advance for your time.
David Romero-Bascones
Hi @Troudi-Abir ,
As a simple approach, assuming you have already reconstructed the streamlines, you could try:
  • Use density_map to build a density map of each bundle in voxel space
  • Binarize the density map to obtain a bundle mask (set to 1 all voxels !=0)
  • Compute the bundle volume as the product between the number of voxels in the mask and the volume of a single voxel
hello @drombas thank you very much for your help.
I want to know how to calculate the volume in each hemisphere, in other words,
how I can divide the brain to calculate the volume of the bundle in each hemidphere apart?
Hello again, please could you privide me with an exemple to calculate mean_curvature with DIPY? I will appreciate your help. Thank you
Yun Wang
Hi All, I wonder if the slides in the workshop are available ?
Serge Koudoro
Hi @wangyuncolumbia, no they are not available but you can always ask directly the speaker by sending an email
Hi @Troudi-Abir, I recommend you to look at the documentation concerning the mean_curvature, it should be straight forward: https://dipy.org/documentation/1.4.0./reference/dipy.tracking/#mean-curvature
Dear @skoudoro thank you very much for the information, It's well appreciated.
Ariel Rokem
Is there a way to save png files of a particular view from horizon? I think that it used to be possible to save out a png with the s key, but I don't think that feature was deprecated (?). Also, is there any way to control the resolution of the output?
2 replies
I come back to the mean_cuvature function, I want to calculate mean_curvature of a bundle.tck, so I wrote this command line : MC=mean_curvature(bundle),
and I get an error that says the shapes are not compatible, I could not apply this function, could you help me please.
Dear All,
Bruno Moretti
Hi all! I don’t work with MRI images but with confocal microscopy 3D images. I have images that I need to align in 3D, and I think that an approach such as the one used in DIPY affine registration should work well. However, I’m struggling to use DIPY with my images, since the format of my images is different (they're just regular 3D (x,y,z) numpy arrays). In particular, when I try to call functions such as transform_centers_of_mass, I’m lacking the static_grid2world and moving_grid2world parameters. Is there any way to obtain the grid2world parameters from the raw, non-MRI images? Thanks a lot!
@venkatbits Dear All, I am unable to find a tutorial or a documentation page for reconstructing fibers tracts based on deterministic approach for a simple 12 directional diffusion 'tensor' fit data. Can anyone kindly help me in giving the steps for deterministic tractography after 'tensor fit' to the DWI images.
Hello everyone,
I just started exploring the dipy library, starting from the tutorial.
So far I understand every step that is explained, except for the white matter mask part.
As I tried to use my own data to perform the tractography, I can not use the labels and the white matter mask provided by the example in the tutorial (the one from Stanford), as the dimensions are very different.
I have tried also just to use a whole brain mask produced using the median_otsu step, however the resulting figure was not satisfactory for a healthy participant (mostly only fibers in the right hemisphere were tracked).I suspect this mask could be the problem, but I'm aware too that these two problems could be independent of one another, so any help would be much appreciated!
Thank you
Dear All, I am unable to find a tutorial or a documentation page for reconstructing fibers tracts based on deterministic approach for a simple 12 directional diffusion 'tensor' fit data. Can anyone kindly help me in giving the steps for deterministic tractography after 'tensor fit' to the DWI images.
Dear all, I'm trying to develop a pipeline that uses dipy functions (that have been very useful so far). But I am a bit confused by the adc function in dti.py since it uses the sphere362 in the data folder, instead of the given acquisition b values and vector directions. Is there any way to get the ADC values from a monoexponential model fitting as in https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4709925/ with bvecs provided as in during acquisition instead of sphere directions (nor b values converted to 1 as in the function) and thus end up with Xaxisvoxels x Yaxisvoxels x Slices X NumberofAcquisitionDirections nifty file instead of Xaxisvoxels x Yaxisvoxels x Slices X 362 due to sphere as happens by default? Thanks in advance and hope the question isn't confusing. I was just surprised since MD, FA etc. parametric maps in dti tutorial for example do use the bval bvec from your scan, unlike the adc function
Ariel Rokem

@jarcosh : yes! Instead of the 362-vertex sphere, you can create your own sphere:

from dipy.core.sphere import Sphere
my_sphere = Sphere(xyz=gtab.bvecs[gtab.b0s_mask])

Where gtab is a gradient table based on your data.