nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
654 stars 258 forks source link

(Question- Wishlist) Are there any plans on Julia API? #990

Closed ekurtulus closed 3 years ago

ekurtulus commented 3 years ago

I am developing a neuroimaging related project with Julia programming language and saw that Julia lacks such a package of quality. Are there any plans on embeddings to different programming languages?

effigies commented 3 years ago

Hi Emirhan. I don't know a lot about Julia, but I have a hard time believing that interfacing with a Python library would be efficient or easy to work with. I do think NiBabel is a very readable implementation of a number of formats, so it could be a good reference for someone wanting to implement the file structures in Julia.

ekurtulus commented 3 years ago

Thank you for your kind explanation on this. Actually, I thought that there is a C++ library working behind and made this request with that in mind. However, as I dug deeper into the source code, I saw that it is pure Python based on Numpy. In this case it would be illogical to create interfaces for other languages.

YSanchezAraujo commented 3 years ago

incase anyone is curious (at the risk of stating the obvious), you can use all of nibabel's functionality with 2 lines of code in Julia:

Using PyCall;
nb = pyimport("nibabel");

the only requirement being that nibabel and any dependencies are already installed in python on your machine, and that the following is set (in say a REPL session) ENV["PYTHON"]="\the\path\to\your\python\bin" (you only need to set that one time), now you can use nb the same way as you'd use it if you did import nibabel as nb in python

ekurtulus commented 3 years ago

Yes, PyCall is a convenient tool; however, when one deals with large datasets and projects, the inner workhorse of it becomes a trouble. Because PyCall creates a Python session and runs the commands via it. As one can see, this causes a great inefficiency (compared to native code) due to constant conversions of data types, not to mention perfomance reduction as a result of run-time compilation and possible memory/ compatibility problems especially for a library like Nibabel which aims for convenience and speed for medical image IO/processing. That was the reason I asked for a native Julia port.

YSanchezAraujo commented 3 years ago

Yeah I figured it was something of that sort, but wanted to point that out just in case. https://github.com/JuliaNeuroscience has some interesting development.

Tokazama commented 3 years ago

Hi, I started JuliaNeuroscience. There has a been a ton of work over the last several months aimed at a generic interface for optimized arrays for different CPU and GPU hardware (ArrayInterface.jl). I've been very involved in this and I'm hoping to finalize spatiotemporal traits very soon. The goal is that we can ultimately load neuro formats into Julia and still use cutting edge techniques without any extra effort on the part of the neuroscientist (e.g. no effort converting between in memory formats).

If you're not familiar with Julia it may be worth noting that Julia also has native distributed computing and mapped memory arrays. This means that as support for more formats in the BIDS standard emerge, Julia should be able to support end to end multimodality processing pipelines.