Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 23 15:20
    drombas commented #2625
  • Sep 23 15:05
    codecov[bot] commented #2553
  • Sep 23 14:26
    codecov[bot] commented #2553
  • Sep 23 14:26
    codecov[bot] commented #2553
  • Sep 23 14:25
    drombas synchronize #2553
  • Sep 22 15:50
    skoudoro labeled #2648
  • Sep 22 15:50
    skoudoro commented #2648
  • Sep 22 03:47
    pjsjongsung opened #2648
  • Sep 20 21:21
    skoudoro commented #2626
  • Sep 20 21:01
    pjsjongsung commented #2626
  • Sep 20 20:24
    skoudoro commented #2626
  • Sep 20 18:37
    pjsjongsung synchronize #2626
  • Sep 20 14:50
    skoudoro edited #2625
  • Sep 20 14:50
    skoudoro edited #2625
  • Sep 19 07:53
    skoudoro edited #2369
  • Sep 18 23:35
    codecov[bot] commented #2369
  • Sep 18 22:47
    codecov[bot] commented #2369
  • Sep 18 22:47
    codecov[bot] commented #2369
  • Sep 18 22:47
    skoudoro synchronize #2369
  • Sep 18 22:36
    codecov[bot] commented #2369
Priscilla Galinié
@priscilla-galinie
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
@drombas
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
Troudi-Abir
@Troudi-Abir
hello @drombas thank you very much for your help.
Troudi-Abir
@Troudi-Abir
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?
Troudi-Abir
@Troudi-Abir
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
@wangyuncolumbia
Hi All, I wonder if the slides in the workshop are available ?
Serge Koudoro
@skoudoro
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
Troudi-Abir
@Troudi-Abir
Dear @skoudoro thank you very much for the information, It's well appreciated.
Ariel Rokem
@arokem
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
Troudi-Abir
@Troudi-Abir
hello,
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.
venkatbits
@venkatbits
Dear All,
Bruno Moretti
@bmoretti
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
@venkatbits
@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.
firdausfabrice
@firdausfabrice
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
venkatbits
@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.
jarcosh
@jarcosh
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
@arokem

@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.

jarcosh
@jarcosh
@arokem first off, thanks for the very quick response. hope my reply isn't overly long or any remaining problems down to the fact it's been a few years since I last routinely did linear algebra :-) I did what you advised. strangely enough the code exactly as you sent me left me with a gtab object with the True and False in b0s_mask inverted (so the sphere generated was a nonsense 0 0 due to two basal images) but once I reverted that it was indeed an sphere with the xyz taking our directions. apparent_diffusion_coef(tenfit.quadratic_form, my_sphere) now produces way more reasonable voxel values than my clumsy attempt yesterday to "fix" the function to force our gtab in. however it's still Xaxisvoxels x Yaxisvoxels x Slices x 14 (since we do preclinical research, it's two b values for each of our 7 directions) instead of Xaxisvoxels x Yaxisvoxels x Slices x 7 directions, so I'm afraid the information we get from using two b values is lost. Additionaly I can't help but notice that apparent_diffusion_coef does away with the original bvals using np.ones to get a fully 1 vector. Trying to document myself I see design matrixes equal a column full of 1s and xn multiplied by intercept and regression line slope, but return D or return D.T gives the column/row of 1s in the 'wrong' place (for last column or a row) and in any case doing design_matrix(gtab)[:, :6] means the 1s row/column is dropped anyway before doing np.dot. Am I doing something wrong, understanding something wrong in how diffusion analysis is usually done or how dipy functions work? Just still a bit puzzled at b values being converted to 1s and then 'dropped'
lastly, now I also get a "Vertices are not on the unit sphere." warning, but maybe that's normal due to our handpicked values and 7 vectors not being much of a 'sphere'
rosella1234
@rosella1234
Hi everyone! I have an issue when trying to perform cross-validation for DKI model on 7T data from HCP release. Specifically, the following error appears: File "goodness_of_fit.py", line 46, in <module>
dki_r2 = stats.pearsonr(data_slice[i, j, k, :], dki_slice[i, j, k, :])[0]**2
File "/home/rosella/anaconda3/lib/python3.8/site-packages/scipy/stats/stats.py", line 3868, in pearsonr
normym = linalg.norm(ym)
File "/home/rosella/anaconda3/lib/python3.8/site-packages/scipy/linalg/misc.py", line 140, in norm
a = np.asarray_chkfinite(a)
File "/home/rosella/anaconda3/lib/python3.8/site-packages/numpy/lib/function_base.py", line 485, in asarray_chkfinite
raise ValueError(
ValueError: array must not contain infs or NaNs
I do not know how to solve this and why it just happens for 7T data, unlike 3T . thanks
Eleftherios Garyfallidis
@Garyfallidis
@willi3by DBSI fitting is not available. However, if it is clear that DBSI is more advantageous than other implemented models for x reasons it makes sense to implement it. We may need to contact the authors. Be happy to start a discussion topic here https://github.com/dipy/dipy/discussions Please start the discussion by providing a summary of reasons that justify the time commitment.
Ariel Rokem
@arokem
@rosella1234 : looks like there are some nans in that data. You might want to filter out voxels with nans before performing your correlation analysis
@jarcosh : oh yes, that should have been my_sphere = Sphere(xyz=gtab.bvecs[~gtab.b0s_mask])
But it looks like you've solved that already. Let me see if I can address the other issues:
Regarding the 7 vs. 14 directions: Don't you get the same ADC value for the two vectors representing the same direction?
I think that should be the case (and should incorporate information from both b-values, although you should be careful with that, especially if the higher b-value is higher than b=1,000, because the signal is probably not a Gaussian in many places.
Ariel Rokem
@arokem
I am not sure that I follow the question about the design matrix. In case it helps, take a look at equations 6 - 9 in this paper: https://www.sciencedirect.com/science/article/pii/S1053811906007403.
jarcosh
@jarcosh
@arokem I feel silly now: you are completely correct that the ADC values for the two vectors representing the same direction are exactly the same. Being happy the voxels values now seemed reasonable/annoyed that the output still seemed in the wrong dimensions and having other issues to solve I didn't compare ROIs thoroughly as I usually do and didn't notice.
So moved on to something else and noticed just now. Will compare output from our other software to dipy values but as far as using dipy correctly goes I managed thanks to your advice. Your reference seems a better explainer than the one I linked, so thanks for that too, will read carefully edit: (and yes, the formula 9 clarifies how it actually works/how dipy manages and clears my confusion there too)
rosella1234
@rosella1234
@arokem thank you! Should I replace NaNs with something else in image matrix, then?
Steven Meisler
@smeisler
I am have a tck tracogram and want to use voxel2streamline to see which streamlines pass through which voxels. I feed in the streamlines and the inverse of the DWI affine to map from streamline to voxel. I am having trouble interpreting the output, as I do not know how to map voxel index to location. Any guidance would be appreciated, thanks!
Steven Meisler
@smeisler
it appears dipy.tracking.vox2track.streamline_mapping is better suited for my needs
willi3by
@willi3by
Thank you @Garyfallidis ! I will start the discussion
Eleftherios Garyfallidis
@Garyfallidis

Hi Everyone! We are very happy to announce that a new educational course is available online: https://youtube.com/playlist?list=PLRZ9VSqV-6soOC0rUEAOV-QiSa_Qxk8JM :rocket: This is a complete course on Diffusion MRI with Theory and Practice :snake: This is your chance to go from zero-to-hero in using :star: DIPY :star: Topics include -
:white_check_mark: dMRI Basics
:white_check_mark: Microstructure Modeling
:white_check_mark: Denoising
:white_check_mark: Tractometry
:white_check_mark: Dictionary Learning
:white_check_mark: Advanced Multidimensional Diffusion Encodings
:white_check_mark: Registration
:white_check_mark: Tissue Classification
:white_check_mark: Deep Learning methodologies in MRI
:white_check_mark: High Field MRI
:white_check_mark: GPU Acceleration
:white_check_mark: Data Harmonization
:white_check_mark: ML in the Clinic and much more.....

Do not miss out on this golden opportunity! If you do like and use DIPY please do give us a star and cite the piece of software that you are using! It encourages us to keep going! May your data live a new life!!

Oliver Li
@motivationss
Hi everyone! I have an issue when trying to transform streamlines into the original 3D coordinates. I have found several functions to transform the 3D coordinates to streamlines but not vice versa. I am inquiring if we have one function for such purpose in dipy or not.
Eleftherios Garyfallidis
@Garyfallidis
@motivationss are you using the Stateful Tractogram?
AtulPhadke
@AtulPhadke
Hello everyone. I am having an error on dti with nifti images. Here is the source code.
fbval = f'{file2_path}.bval'
fbvec = f'{file2_path}.bvec'
                    data, affine, img = load_nifti(file2_path, return_img=True)

                    bvals, bvecs = read_bvals_bvecs(fbval, fbvec)
                    print(bvals)
                    gtab = gradient_table(bvals, bvecs)

                    print(gtab)

                    tenmodel = TensorModel(gtab)

                    print(len(bvals))

                    new_img = img.get_fdata()                

                    tenfit = tenmodel.fit(new_img)
The error I am getting is this
Traceback (most recent call last):
File "main.py", line 197, in <module>
convert(args.f1t, args.f2t, args.f1p, args.f2p, args.s, args.diff)
File "main.py", line 171, in convert
tenfit = tenmodel.fit(new_img)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dipy/reconst/dti.py", line 793, in fit
self.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dipy/reconst/dti.py", line 1303, in wrapped_fit_tensor
*args,
kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dipy/reconst/dti.py", line 1381, in wls_fit_tensor
w = np.exp(np.einsum('...ij,...j', ols_fit, log_s))
File "<__array_function__ internals>", line 6, in einsum
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/core/einsumfunc.py", line 1356, in einsum
return c_einsum(operands, *kwargs)
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (10,10)->(10,10) (10000,11)->(10000,newaxis,11)
I have tried everything including this link right here, dipy/dipy#1790, but it still does not work for me
Oliver Li
@motivationss

@motivationss are you using the Stateful Tractogram?

Thanks for your reply. No, I did not use the Stateful Tractogram and I generated streamlines from fiber tracking.

Ajay Bhargava
@ajay_bhargava_twitter
I have registered two volumes using dipy.align._public.SymmetricDiffeomorphicRegistration. Using the .update() method, I have interpolated the displacement to a new 3D shape of (S,R,C,3). I would now like to split this 3D array into a list of 2D arrays and then apply each deformation field on a new 2D image. Is there a way of doing that?
Ajay Bhargava
@ajay_bhargava_twitter
Specifically, is there a way of applying a deformation field from the map.forward() attribute on a new image? I want to save these deformation fields for later use.
AlexBadea
@portokalh
anybody can suggest how to move fwds past this error message when using dipy_horizon: "TypeError: buffer is too small for requested array"? thanks much! alex
Eleftherios Garyfallidis
@Garyfallidis
@portokalh what was the input? And how did you run the command?
Eleftherios Garyfallidis
@Garyfallidis
@AtulPhadke can you print data.shape and new_img.shape?
araikes
@araikes
Is there a CLI approach where I could use an existing mask to crop an image? dipy_median_otsu has the --autocrop option but that computes another mask potentially unnecessarily.
Mohammad Hadi Aarabi
@mohammadhadiarabi
I have a question, If I have multishell data and going to fit my data to tensor model, how can I select bval = 0 and 1000 of my data.