Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ex-vivo data, weird values #159

Open
reveley opened this issue Mar 18, 2023 · 11 comments
Open

ex-vivo data, weird values #159

reveley opened this issue Mar 18, 2023 · 11 comments
Assignees

Comments

@reveley
Copy link

reveley commented Mar 18, 2023

Hi - I'm using AMICO to test different NODDI values in high resolution ex-vivo data. The data is at 160um. bvals and bvecs attached. Seems to work ok in the matlab NODDI code. no problems fitting a tensor.

I ran it with standard NODDI settings to start with. It's come out with an odd distribution of values. I could use a hand fixing this.

many thanks

image

image

bvals/bvecs:

0 0 0 0 0 0 0 0 30 30 30 30 30 30 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 2400 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800 4800

0 0 0 0 0 0 0 0 0.0855499 -0.336449 0.691491 -0.133902 -0.84655 0.81659 -0.409676 -0.883741 -0.898323 -0.23675 -0.509532 0.0596604 0.933636 0.0144401 0.832172 0.54514 0.944306 0.794213 -0.270394 -0.584977 0.83498 0.408992 0.6497 -0.862535 -0.975354 0.77184 -0.226798 0.949666 -0.148085 -0.0939421 -0.700476 0.110849 0.375008 -0.870828 -0.503055 -0.429359 0.0654165 -0.716597 -0.245933 0.210261 -0.0799982 0.500919 0.502539 0.636351 0.418896 -0.674218 0.233592 0.372689 0.620514 -0.73428 0.142788 0.329034 -0.0988194 0.211646 -0.210719 -0.677529 -0.984372 -0.398305 -0.809106 0.553786 -0.201321 0.691132 0.0735422 0.351675 -0.489878 -0.41715 0.631529 0.796923 -0.699833 -0.453851 0.0205968 0.677389 -0.0955324 -0.0810379 -0.231957 -0.33615 0.765058 0.530622 0.720499 0.18522 -0.972279 -0.634372 0.554245 -0.79675 0.179961 0.0347061 0.631941 -0.856027 0.886592 -0.0503631 -0.340715 0.750122 0.347145 0.202977 0.227697 -0.110479 0.0662979 -0.026798 -0.101891 -0.0499228 -0.486274 -0.0798083 0.750979 -0.937616 0.893549 0.880872 0.867929 -0.247651 -0.831151 -0.808143 0.51628 0.0422699 0.0763816 0.872196 -0.414344 -0.656355 0.960893 -0.785148 0.499496 0.204333 -0.771473 -0.332078 -0.823365 -0.45253 0.31826 -0.402796 -0.921048 0.801388 -0.576024 0.988743 -0.397284 -0.902489 0.490851 0.106094 0.311329 0.691892 0.860483 0.77044 -0.566231 -0.270991 0.945749 0.0417252 0.981205 0.35237 0.530856 -0.7135 0.5497 -0.552451 -0.31087 -0.759201 0.756755 -0.151208 0.48944 -0.532641 0.306227 -0.608161 -0.935634 -0.655592 0.142653 -0.424738 0.88744 -0.267417 0.381794 -0.259659 0.91857 -0.999209 0.652173 0.0798155 0.480806 0.64011 0.405642 -0.397078 -0.218365 0.216914 0.386139 -0.683384 -0.797411 -0.564061 -0.639241 -0.28148 0.57601 0.224872 -0.702063 0.367642 -0.785131 -0.948231 0.27403 -0.139374 0.666982 -0.0587127 0.367065 0.482426 -0.551405 -0.562771 -0.371856 0.140005
0 0 0 0 0 0 0 0 -0.24226 0.670845 0.495229 -0.963264 -0.230603 -0.514766 -0.236554 0.444084 0.229677 0.546564 0.562119 -0.0403216 0.117143 -0.95588 0.411113 -0.330722 0.314499 0.601602 0.0310489 0.0369121 -0.51644 -0.599939 -0.0367465 -0.251548 -0.146294 0.203139 0.922511 -0.218527 0.988823 0.307276 0.30893 -0.616775 0.874385 -0.45539 0.770257 0.304162 0.623291 -0.527147 0.771434 -0.836839 -0.334234 -0.751259 0.22837 0.692578 0.707766 -0.241139 -0.33942 -0.0400033 -0.771383 0.530998 0.844655 -0.916571 -0.827052 0.242732 -0.976563 -0.706688 0.154953 -0.736318 0.0181743 0.83082 -0.598557 -0.515472 0.968658 0.498823 -0.492217 -0.872537 0.481574 -0.226431 0.696228 0.885759 0.915679 0.716817 0.0556174 -0.155523 -0.946959 -0.479255 0.584995 0.814705 0.531666 -0.921828 0.0453878 -0.475625 -0.625806 -0.596779 0.49926 0.997371 -0.709869 0.404277 0.462507 -0.990837 0.828725 -0.565678 0.336727 0.913737 -0.704176 0.664779 -0.785496 0.80038 0.975899 -0.684829 -0.78015 -0.498842 -0.652203 0.280361 -0.447761 -0.373095 -0.0541358 0.208681 -0.415465 0.585466 0.0407632 -0.888134 0.361548 0.448956 0.130594 0.48293 -0.271707 0.565451 0.396335 0.0633536 -0.571159 0.645628 0.190128 0.700436 0.821348 0.47688 -0.281721 -0.378637 0.215256 -0.0691635 -0.914355 0.0560925 -0.829645 -0.465713 -0.949008 -0.373342 0.23877 0.0233592 -0.143565 0.385337 -0.0632599 0.183573 0.134767 -0.849329 -0.155659 0.13308 -0.487652 -0.82171 -0.845843 -0.344166 0.37028 0.870124 0.767082 -0.326592 0.645925 0.79293 -0.106672 0.67487 0.73556 -0.0585258 -0.221604 -0.151877 -0.73137 -0.335771 0.283383 -0.023471 0.317985 -0.256414 0.562853 0.141659 0.905386 0.877141 -0.728688 -0.125365 -0.3947 -0.729703 -0.162628 0.393142 -0.670681 0.949637 0.632864 0.964701 -0.0605216 -0.220054 0.371161 -0.306578 -0.542238 -0.913112 -0.212143 0.504501 0.139677 -0.872169 -0.634858 0.796197 -0.625095 -0.976565
0 0 0 0 0 0 0 0 0.966432 0.660885 0.525916 0.232794 0.479766 0.261145 0.881026 0.147618 0.374518 0.803254 0.651459 0.997404 0.338527 0.293403 0.372124 0.770354 0.0968322 0.0854438 0.962249 0.81021 0.189994 0.687604 0.759302 0.43904 0.165176 0.602492 0.312309 0.224456 0.0172914 0.946972 0.643347 0.779295 0.30793 0.185142 0.391969 0.850374 0.779249 0.456733 0.586862 0.505461 0.939089 0.429755 0.833848 0.339696 0.568853 0.698056 0.911169 0.927094 0.141178 0.422935 0.515917 0.227232 0.553371 0.946724 0.0438383 0.203831 0.0836712 0.546981 0.587381 0.0553177 0.775371 0.506581 0.237261 0.792149 0.719543 0.254292 0.607665 0.560038 0.159686 0.0972091 0.401383 0.165278 0.993871 0.984503 0.222405 0.810751 0.269198 0.233873 0.445211 0.340481 0.229376 0.609387 0.548799 0.0951001 0.847558 0.0636095 0.311024 0.322147 0.006484 0.125321 0.443991 0.342529 0.875275 0.351973 0.672525 0.738825 0.615305 0.598894 0.192975 0.726991 0.393578 0.863011 0.103257 0.205605 0.032868 0.291315 0.493729 0.946109 0.369563 0.0642945 0.855449 0.457637 0.929219 0.194198 0.900702 0.579635 0.0534722 0.252601 0.770339 0.976849 0.280367 0.687669 0.534716 0.551912 0.473389 0.781243 0.268892 0.463045 0.788582 0.132681 0.0782367 0.427044 0.265997 0.878553 0.0495672 0.617982 0.450064 0.637085 0.811647 0.882088 0.31868 0.98212 0.13811 0.393034 0.833044 0.687901 0.678252 0.139966 0.433485 0.552417 0.538715 0.469064 0.414769 0.780789 0.69929 0.0374545 0.336467 0.338748 0.66227 0.903423 0.404156 0.951536 0.565094 0.905448 0.275542 0.032091 0.688154 0.963266 0.672326 0.755111 0.125421 0.270096 0.6491 0.968107 0.833732 0.0228081 0.581109 0.726137 0.376242 0.137691 0.517393 0.137055 0.709538 0.903557 0.49579 0.0828768 0.794283 0.383145 0.714234 0.861413 0.919649 0.0811522 0.54121 0.222171 0.686279 0.163461

@reveley
Copy link
Author

reveley commented Mar 18, 2023

I will say that the second image showing the broad spatial distribution of values looks about right - it's just the weird histogram that is a problem.

@nightwnvol
Copy link
Collaborator

nightwnvol commented Mar 19, 2023

Did you set the parameter isExvivo=True after choosing the NODDI model?

import numpy as np

# default NODDI dictionary
dPar = 1.7e-3
dIso = 3.0e-3
IC_VFs = np.linspace(0.1, 0.99, 12)
IC_ODs = np.hstack((np.array([0.03, 0.06]), np.linspace(0.09, 0.99, 10)))

ae.set_model('NODDI')
ae.model.set(dPar=dPar, dIso=dIso, IC_VFs=IC_VFs, IC_ODs=IC_ODs, isExvivo=True)

@reveley
Copy link
Author

reveley commented Mar 20, 2023

I have not, yet. However the MATLAB NODDI toolbox gives a different result to AMICO using these same default parameters. Part of the purpose of my study is to assess NODDI under different parameter regimes, so ideally AMICO and the original NODDI code would produce the same results when given the same parameters. I can check again to be sure all the params are identical. I don't really know what IC_VFs and IC_ODs are, I presume these are to do with how AMICO is estimating the model.

@daducci
Copy link
Owner

daducci commented Mar 20, 2023

Dear @reveley ,

The issue you are experiencing is discussed here (#8). Long story short: AMICO is not the same as "MATLAB NODDI" but it represents an approximation of it to speedup the fit. As an effect of this, even though the maps estimated by the original MATLAB implementation and AMICO usually look identical, if one looks at the corresponding histograms these "weird bumps" appear. This is indeed due to the discretization of the possible values when building the linear operator but, until now, this does not seems to have any particular side effect (besides the weird-looking plots!). Can you confirm, though, that the maps estimated by AMICO and MATLAB are very similar, indeed? (i.e. you posted just one screenshot, it'd be interesting to have a look at both)

Best,
Ale

@reveley
Copy link
Author

reveley commented Mar 20, 2023

Hi Ale -

I only processed one slice with the NODDI MATLAB so far, and the only one I could find uses different diffusivities, so the values are different. But the spatial distribution is the same. I'm only looking at gray matter at the moment, AMICO is giving most white matter values as 1.

It's not just a weird looking histogram, AMICO is putting most of the data into those clipped histogram bins.

Maybe IC_VFs needs to be finer grained?

image

@daducci
Copy link
Owner

daducci commented Mar 20, 2023

Did you set the same diffusivities you used for the MATLAB implementation also for AMICO? Usually, when AMICO return "saturated" values it is because the diffusivities are not correct for the data at hand.

@reveley
Copy link
Author

reveley commented Mar 20, 2023

No, but I did run the MATLAB code with the same diffusivities as AMICO and it came out OK. I just cannot find that test at the moment. I'll run AMICO with the right diffusivities and see how that goes.

thanks

Colin

@reveley
Copy link
Author

reveley commented Mar 21, 2023

Hi - I ran it with these parameters as suggested:

dPar = 1.7e-3
dIso = 3.0e-3
IC_VFs = np.linspace(0.1,0.99,12)
IC_ODs = np.hstack((np.array([0.03,0.06]),np.linspace(0.09,0.99,10)))

Although the white matter now has a more sensible range of values, unfortunately the issue still persists and the histogram looks like this:

image

I'd be happy to read through the long thread you referred to; When I skimmed it yesterday I noticed something about a MATLAB version of AMICO with some code that might fix this problem.

At the moment I have limited access to equipment, so that it is taking me 8 days to fit a NODDI model to this one brain sample using matlab on a quad core CPU. The machine does have a GPU but it might be too old to run the FSL GPU code. Not sure. So I could really use something like AMICO to fit multiple paameter sets and subjects, and ideally publish the results.

many thanks

Colin

@daducci
Copy link
Owner

daducci commented Mar 22, 2023

Hi Colin,

Long story short: yes, the discretization "prefers" some values over others, but the differences are minor and should not constitute a problem. I agree, the histograms look weird, though. As a workaround (ad discussed in the thread I linked) is to blur a little bit your final images and this effect should disappear. I tested on HCP data and applied a Gaussian blut with sigma=0.75 mm. You can achieve that using, for example:
fslmaths FIT_ICVF.nii.gz -s 0.75 FIT_ICVF_smooth.nii.gz
or
c3d FIT_ICVF.nii.gz -smooth .75x.75x0mm -o FIT_ICVF_smooth.nii.gz

Attached some results, before and after blurring; images look essentially the same, but now the histograms look less weird.

Can this do the trick for your application?

Screenshot 2023-03-22 at 13 52 31

@reveley
Copy link
Author

reveley commented Mar 22, 2023

Hi Ale - i did notice that applying a gaussian helped. It's not quite right for my application, because I want to correlate NODDI against other non-gaussian maps, and so I really need to minimise any exogenous differences. But it's ok, I can sill use AMICO to find the best parameters.

thanks

Colin

@nightwnvol
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants