ME-ICA / aroma

ICA-AROMA, as a Python package. A work in progress.
Apache License 2.0
7 stars 11 forks source link

Remove non-Python dependencies #1

Open tsalo opened 3 years ago

tsalo commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

tsalo commented 3 years ago

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 Brainhack-Donostia/ica-aroma-org#37).

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

eurunuela commented 3 years ago

I guess we could use nitransforms to replace FLIRT.

eurunuela commented 3 years ago

I guess we could use nitransforms to replace FLIRT.

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

eurunuela commented 3 years ago

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 commented 3 years ago

Do you know if nitransforms can handle nonlinear transforms?

eurunuela commented 3 years ago

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

tsalo commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 Brainhack-Donostia/ica-aroma-org#49 to get the masks used for spatial features.