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

Remove non-Python dependencies #1

Open
tsalo opened this issue Oct 26, 2020 · 12 comments · Fixed by #22
Open

Remove non-Python dependencies #1

tsalo opened this issue Oct 26, 2020 · 12 comments · Fixed by #22

Comments

@tsalo
Copy link
Member

tsalo commented Oct 26, 2020

The current version uses fslmaths for a number of steps that could very easily be done with nilearn or nibabel + numpy.

The only difficult part that I can think of is handling MELODIC's mixture modeling. We can either (1) assume the MELODIC data are in BIDS format already and work from there or (2) try to "implement" the mixture modeling method with a Python-based ICA algorithm.

@CesarCaballeroGaudes
Copy link

CesarCaballeroGaudes commented Oct 26, 2020

Is it really necessary to implement the mixture modelling step? AFAIK, the spatial criteria only require to compute the percentage of the spatial variance in the ventricles or the edges of the brain. If mixture modelling is not required, then we can use the same ICA implementation as in TEDANA. Regardless, the point is whether we really want to substitute the Probabilitic ICA algorithm in MELODIC for the ICA decomposition because that would really alter the results.

@tsalo
Copy link
Member Author

tsalo commented Oct 26, 2020

I think that mixture modeling is necessary based on the blockers I came up against the last time I tried this conversion, but (1) I can't be sure I did the conversion correctly and (2) the official version of the code is, unfortunately, nearly unreadable. It should be easier for us to see if mixture modeling is necessary once we have thoroughly refactored the code.

@eurunuela
Copy link
Collaborator

Definitely. Once the code is refactored, it will be much easier to see what's missing and what our next steps should be.

@tsalo
Copy link
Member Author

tsalo commented Nov 5, 2020

I think the most important remaining FSL code is:

  1. MELODIC for ICA and mixture modeling.
  2. FLIRT for applying linear transforms from native-space data to standard space.
  3. apply_warp for applying warps from native space to standard space.
  4. fsl_regfilt for denoising (see Replace regfilt with Python code Brainhack-Donostia/ica-aroma-org#37).

I think the rest of the remaining non-Python code could be replaced fairly easily.

@eurunuela
Copy link
Collaborator

I guess we could use nitransforms to replace FLIRT.

@eurunuela
Copy link
Collaborator

I guess we could use nitransforms to replace FLIRT.

I'm trying to see how we can do this.

@eurunuela
Copy link
Collaborator

eurunuela commented Nov 6, 2020

I believe we have to do something like this for the affine:

xfm = nt.linear.Affine(afnixfm.to_ras(reference=new, moving=new), reference=new)
nt_with_afni = xfm.apply(new, order=0)

and I guess we can create the iso one ourselves and give it as input:

xfm = nt.linear.Affine(T)
moved = xfm.apply(new, order=0)

I will start a PR and work on this.

@tsalo
Copy link
Member Author

tsalo commented Nov 6, 2020

Do you know if nitransforms can handle nonlinear transforms?

@eurunuela
Copy link
Collaborator

I think it can but I would have to look into that.

@tsalo
Copy link
Member Author

tsalo commented Nov 7, 2020

Now that we're planning to drop transforms (see Brainhack-Donostia/ica-aroma-org#45) for the immediate future, I think all we need to do now is figure out how to replace MELODIC's mixture modeling.

@tsalo
Copy link
Member Author

tsalo commented Nov 8, 2020

Is anyone familiar with nipy's Gaussian Gamma mixture model? See here and here. I think that a Gaussian Gamma mixture model is the one used by MELODIC.

@tsalo
Copy link
Member Author

tsalo commented Nov 8, 2020

I think we can also leverage tedana in replacing MELODIC. Something like the following:

  1. tedana's MAPCA function in tedana to get number of components and dimensionally-reduced data.
  2. tedana's TEDICA function to get component time series and maps.
  3. Corrected version of tedana's computefeats2() to get component z-statistic maps. (We need the fixed version for this.)
  4. nipy's GMM to threshold component maps.
  5. FFT using tedana's plotting code to get the component power spectra.
  6. Code proposed in [ENH] Derive masks to support native-space data Brainhack-Donostia/ica-aroma-org#49 to get the masks used for spatial features.

@eurunuela eurunuela transferred this issue from Brainhack-Donostia/ica-aroma-org Nov 10, 2020
@eurunuela eurunuela added the Refactoring Significant changes to the code label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants