ME-ICA / multi-echo-data-analysis

Still a work in progress.
https://me-ica.github.io/multi-echo-data-analysis/
GNU Lesser General Public License v2.1
3 stars 2 forks source link

Use Python code for 3dMEPFM #3

Open tsalo opened 3 years ago

tsalo commented 3 years ago

@eurunuela is working on a Python implementation of 3dMEPFM, so we can use that instead of AFNI (which is harder to install for a Jupyter Book) once it's available.

Original content

I'm thinking that we should use the 3dMEPFM R code directly, rather than installing AFNI. To that end, we'll need to include R dependencies and have the relevant notebook use an R kernel instead of Python.

tsalo commented 3 years ago

@eurunuela I'm not really experienced with R. Is there any kind of equivalent to requirements.txt or setup.py for R code? Something that will define the necessary dependencies for our Jupyter notebooks?

eurunuela commented 3 years ago

@eurunuela I'm not really experienced with R. Is there any kind of equivalent to requirements.txt or setup.py for R code? Something that will define the necessary dependencies for our Jupyter notebooks?

Good question. I have never written an entire library in R, I've only written scripts, so I honestly do not know.

I guess we could create an R script that installs the libraries anyway 🤔 Not sure that's how R libraries handle it.

eurunuela commented 3 years ago

A quick Google search has led me to the a documentation site that explains how to do it: https://r-pkgs.org/description.html

tsalo commented 3 years ago

Can 3dMEPFM operate using pure R? As in, without any AFNI C code? I just wonder if maybe 3dMEPFM could be packaged as an R package, or even all AFNI R functions together in one.

eurunuela commented 3 years ago

Can 3dMEPFM operate using pure R? As in, without any AFNI C code? I just wonder if maybe 3dMEPFM could be packaged as an R package, or even all AFNI R functions together in one.

Yes. That's doable. It runs R only and has an AFNI compatible CLI.

tsalo commented 3 years ago

It looks like John Lee started on something to that effect (https://github.com/afni/afnistats), but I don't think it ever got published to CRAN or anything.

eurunuela commented 3 years ago

If adding R dependencies is too much work, another option would be to wait for the Python version we're currently working on, estimation of global fluctuations included.

tsalo commented 3 years ago

😆 Yeah that sounds better! Any clue on a timeline?

eurunuela commented 3 years ago

Code is pretty much ready, working on the paper now. Should be there before the end of the year.

tsalo commented 2 years ago

@eurunuela any update on this?

eurunuela commented 2 years ago

@eurunuela any update on this?

Working on improving one of the versions. Once I'm happy with it, I'll make the repo public and I'll add a Zenodo DOI.

tsalo commented 2 years ago

Thanks @eurunuela!

eurunuela commented 2 years ago

This is not the PFM version I referred to in my previous comments but should be good enough to use as an equivalent to 3dMEPFM: https://github.com/eurunuela/pySPFM

I'll work on adding some examples to the README.

tsalo commented 2 years ago

@eurunuela the most recent release doesn't have all of the necessary dependencies listed, but I think you fixed that problem in a later commit. Can you make a new release?

eurunuela commented 2 years ago

I just made a new release. Have you tried running it?

I must warn you that I have only tested some parts of the code, but not everything. I am currently on the process of moving all the code I've written in the past 4 years into 3 proper Python packages. So some things may be broken atm.

tsalo commented 2 years ago

It looks like the Action that deploys to PyPi didn't succeed.

eurunuela commented 2 years ago

I see. I'll have a look at it tonight or tomorrow and get back to you.

tsalo commented 2 years ago

No rush. I just had a few minutes and decided to add the dependency. I can totally wait before circling back to this.

eurunuela commented 2 years ago

No rush. I just had a few minutes and decided to add the dependency. I can totally wait before circling back to this.

I just deployed to PyPi from my computer. I don't know why the Action failed.

tsalo commented 2 years ago

It's now installing correctly, but the new problem is the AFNI dependency. I've opened an issue in the pyspfm repo about it.

eurunuela commented 2 years ago

It's now installing correctly, but the new problem is the AFNI dependency. I've opened an issue in the pyspfm repo about it.

If the AFNI dependency is not a problem, you can already use the package.

I have already dropped the dependency to generate the HRF matrix, but I still have to find a way to make nibabel write to the history section of the header of the output nifti files.

tsalo commented 2 years ago

I could probably use the AFNI+miniconda Docker image you were using for pyspfm's CI, but I'd definitely prefer to use pure Python in the future, so I'm hoping there will be a good way to update BRIK/HEAD files in the near future. 🤞

eurunuela commented 2 years ago

I could probably use the AFNI+miniconda Docker image you were using for pyspfm's CI, but I'd definitely prefer to use pure Python in the future, so I'm hoping there will be a good way to update BRIK/HEAD files in the near future. 🤞

I agree it would be nice to have a pure Python version. But right now, adding this feature to nibabel is not the main priority for me. If someone develops it, I will happily include it to pySPFM.

tsalo commented 1 year ago

Per @eurunuela in this week's tedana devs call, the pure Python version of pySPFM should be good to go! I will try using it soon.