funkelab / gunpowder

A library to facilitate machine learning on multi-dimensional images.
https://funkelab.github.io/gunpowder/
MIT License
79 stars 56 forks source link

Understanding request dependencies #202

Closed moenigin closed 2 months ago

moenigin commented 10 months ago

Hi,

I want to write my own augmentation nodes because my data shows artefacts that are not mimicked by the nodes available in the package (SBEM data). In that context I wanted to understand when the prepare should return dependencies. Specifically, I was wondering why NoiseAugment and IntensityAugment update the array specs of the raw data with a copy of the requested specs. It seems redundant and I could run it without. However, I am wondering if there is some situation in which this might fail/produce problems if the dependencies are not explicitely returned? I am new to this and trying to wrap my head around how a pipeline is put together and won't to avoid issues popping up in the training midways. Thanks a lot for your feedback! Nila

pattonw commented 7 months ago

In general the prepare method is supposed to only return the dependencies necessary for the node and should not modify the request in place. Best practice is just to create a new BatchRequest, and fill it with the dependencies of your node. This allows gunpowder to provide only the requested data in the batch argument of process. This simplifies the logic in each node so each node doesn't have to check for intersections/unions of Rois to see if more data was fetched than necessary due to other nodes potentially requiring more context. This is now all handled in the background by logic in BatchFilter