Repository navigation
Closed
Labels
Description
Description
This is meant to supersede the discussion in #1605, which contains a lot of outdated information.
In 2020, here are the pros for replacing skimage.io with imageio:
- distributing wheels is easy now
- imageio has feature parity with
skimage.io. In fact, I would be surprised if 99% of ourio.imreadcalls didn't go straight through to imageio — at least if we exclude tifffile. - this post by @danielballan, for those that haven't seen it, gives a rough outline for implementing a single protocol for lazy image reading in Python. imageio is a natural place to implement such work, and
skimage.iois at best redundant, at worst, another place for things to fall out of sync.
Things that I think need to change in imageio for us to completely drop skimage.io:
- imageio.imread does return a fancy array wrapper rather than a straight numpy array, which breaks the scikit-image API. However, this is somewhat necessary for imageio to provide metadata. Not sure where to meet on this one.
- imageio.imread only gets a single plane out of a tiff file, preferring to leave volume loading to
imageio.volread. imho we should aim to be dimension-agnostic. @almarklein is this something you foresee could change? See e.g. reading array of shape (512, 512, 30) with a pathlib path returns array of shape (512, 30) #4138.
In my opinion, the existence of both skimage.io and imageio is redundant, and it makes sense to separate the two functionalities (IO vs processing/analysis) into two separate packages.
@emmanuelle argues for keeping imread. I'm ok with that but I also would contemplate removing it for 1.0.
Definition of done: All external plugins and functionality in skimage.io, other than ImageCollection, MultiImage, load_sift, load_surf, and the imageio wrappers for imread, imsave are removed.
Reacted by Riadh Fezzani, Almar Klein, Lars Grüter and Mikhail Titov
Reacted by Riadh Fezzani
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
sciunto commentedon Oct 27, 2020
+1 with @emmanuelle I beleive it is important to keep wrappers of our io functions because it helps a lot beginners.
rfezzani commentedon Oct 27, 2020
Thank you @jni for opening this, you can't imagine how enthusiastic I am about dropping
skimage.io! 😃I already shared my feelings about this, and I am convinced that
skimagecan gain maturity and stability if it focuses on it's core functionality: image processing!There is plenty of excellent python packages dedicated to IO and viewing. We must advertise for them instead of proposing yet another implementation with all the induced maintenance...
@sciunto, the
skimagedeprecation procedure takes 2 releases before completely removing the deprecated part from the package. I think that this is enough time to teach beginners how to properly read/write images without ourskimage.iomodule 😉almarklein commentedon Oct 27, 2020
I hadn't seen that one yet, but I find the idea of standards (over implementations) very interesting. Also the idea to use
entrypointsfor packages to advertise image/data reading capabilities without importing them is very interesting to scale supported formats without making a lib like imageio "heavy". This needs some more thought ...Perhaps it's finally time to finally fix this long-standing issue ;)
There are some formats that are somewhat ambiguous about whether their data is a set of 2D images or one 3D image. Most notably Tiff and Dicom. In imageio I've made the choice to let the user decide what dimensionality is expected, and pass that hint to the reader. So there's
imread()for single 2D images,mimread()for image series,volread()for volumes andmvolread()for series of volumes.I believe this approach works well. I think that if you'd want to keep an
imread()function in skimage, I'd recommend adding (at least)volread()as well.jni commentedon Oct 27, 2020
Sure, but from a user perspective, we'd want a 3D array in either case, right? For users who work with anything from 2D to 3D+t+c images, having to remember which of the 4 functions to call today is annoying. (Not to mention that sometimes I get user-provided data or downloaded data from a paper and I actually don't know ahead of time the dimensionality.) I believe this is a problem for the metadata, but the data should be a NumPy (or Dask) array, in any case, and so in any case we should use the same function.
almarklein commentedon Oct 27, 2020
I think it's not that simple. Both Tiff and Dicom can provide multiple images (or volumes) of different shapes, so they cannot be stacked into a single array.
Well, you're going to do something with the data, and for that you're assuming a certain shape. I understand that for data exploration it would be nice to see what's actually inside ... which brings us full circle to meta data ;)
jni commentedon Oct 27, 2020
Nope — napari will happily display any shape array. ;)
That is definitely a concern — but one that
volreaddoesn't solve, does it? I would suggestimread(nD image) andmimread(iterator of nD images).almarklein commentedon Oct 28, 2020
Nice! Ok, I see the use-case for an API to just "gimme the data". But I also think there is a need to be able to be more precise.
Somewhere at the plugin level, there is a function
_get_data(index). In a lot of cases the file contains one image,indexis 0, and all is well. In some cases (e.g. video) it's clear thatindexrepresents the nth image. But for e.g. Tiff, the format needs a hint to know whether the user wants the whole thing or is iterating over the slices. Right now, this hint is provided by the user using imshow/mimshow/volshow.Maybe, we could do something along the lines of
imread(hint="greedy"). By default this will try to simply ready all data, but the user can set the hint (or mode?) to '2d' or '3d' to specify a more precise intention if needed.edit: PS: this hint is also used in imageio to select the appropriate format. E.g. Pillow can read gif and Tiff, but not files with multiple frames.
emmanuelle commentedon Oct 29, 2020
My argument in favor of keeping
io.imread: even if we do the deprecation properly etc., it would be a communication/public relations disaster to break 90% of users' scripts. People are going to complain a lot, heavily, and for a long time. We know that there is a long queue of people who upgrade their version only when they really need to, who have a lot of legacy code, etc. If we can help people improving their coding skills this is great, but this is not the right direction IMO. That said, we can have this discussion within the larger context of "what is going to break for users with 1.0" (but I hope that the answer is not 90% of scripts will have to be changed some way or another).Removing the most used function in scikit-image (from this Github crawling which was done a while ago) does not sound like a good idea.
However, I'm very much in favour of making
imreada wrapper as thin as possible aroundimageio, to discard the rest of the API, and to make any further developments inimageio.sciunto commentedon Oct 29, 2020
@emmanuelle I have similar feelings as yours. I would like to add also that some newcomers are lost partly because of the tool segmentation across libraries, which is a natural effect in FLOSS. Thus, I see sometimes scripts mixing pil/scikit-image/opencv merely by ignorance and I'm afraid that some users will search "how to load image in python", and use a library returning a format inappropriate for scikit-image and being lost.
Few wrappers can help the users until they fully understand the machinery. We can also imagine a strategy saying that we regularly reconsider (through web log analysis / forum inspection) if maintaining the wrappers are still relevant.
rfezzani commentedon Oct 29, 2020
I had multiple discussions with other core team members (cc @jni, @hmaarrfk 😉) about breaking changes etc... But I am still not convinced...
People needing their scripts to keep working simply doesn't have to update
skimage! Python environment are made to manage this... Our deprecation strategy is gentle enough to give users time to update their script if needed...We can also rely on our doc to educate new comers to good practices...
I use to think that things evolves naturally, particularly in computer science, and that we don't have to worry much about breaking things... Users usually learn/adapt pretty fast to new behaviors 🙂.
emmanuelle commentedon Oct 29, 2020
In the dev meeting, Almar made an interesting suggestion:
io.imreadas a thin wrapper to avoid breaking people's code.I would be very happy about this trade-off. Thoughts?
rfezzani commentedon Oct 29, 2020
Keeping
skimage.io.imreadis not a big deal. Defining it asdoesn't hurt. My main concern is to keep warning users that it is not the right way to go and to not maintain code in
skimage.io!rfezzani commentedon Oct 29, 2020
In other words, we must say to
scikit-imageusers that IO is no more a target, and that we delegate this toimageiobecause it is dedicated to IO and it manage it way better then we may do.43 remaining items
stefanv commentedon Feb 22, 2023
skimage.iois currently a thin wrapper aroundimageiothat ensures that a NumPy array is returned. We don't plan to change this for the forthcoming release, so I'm bumping the milestone to 0.21.[-]Discussion: deprecating (most of) skimage.io in favour of imageio[/-][+]Deprecate (most of) skimage.io in favour of imageio[/+]mkcor commentedon Sep 8, 2025
I'll close this issue as superseded by #7353 and the discussion in Long-term plan for skimage.io plugin infrastructure referenced therein.