brainglobe / brainreg

Automated 3D brain registration with support for multiple species and atlases.
https://brainglobe.info/documentation/brainreg/index.html
BSD 3-Clause "New" or "Revised" License
121 stars 27 forks source link

Support registration of partial images #6

Closed adamltyson closed 10 months ago

adamltyson commented 4 years ago

As with amap

wudustan commented 3 years ago

Hi Adam. I think we'd like to go ahead and see if we can get this masking approach sorted. I'm happy to try and give adding the functionality in a bash.

adamltyson commented 3 years ago

Hey @wudustan, awesome. There are some old ideas in this issue but the specific implementation would need to be updated for brainreg.

@vigji did you end up getting anywhere registering hemispheres?

adamltyson commented 3 years ago

I think a lot of the work can be done by masking/cropping the target_brain array, somewhere around here. Passing that array to run_niftyreg should hopefully take care of the registration (with some parameter tweaks), but then the deformation field (from sample to atlas space) would need to be edited to ensure that the target space was the full atlas, and not the hemispheres.

wudustan commented 3 years ago

Thanks for that. How would you like to proceed? I'm still trying to understand exactly how the deformation field step works.

adamltyson commented 3 years ago

The deformation field is saved as three separate 3D tiff files, each of which are the same size and shape as the downsampled raw data. They act as a look up, so that for each coordinate in your (downsampled) raw data, you can find the position in atlas space (in mm), in axis 0, 1 and 2 (in each of the files).

If you only pass part of the atlas to the registration step, you should be able to convert the resulting files into a format that is compatible with the "normal" case of using the entire atlas. Then the rest of the pipeline should work as normal. For the images in atlas space, this would be adding padding of the same shape and size that you "cut" from the atlas array in the beginning. For the deformation field, I think something like this should work:

Does any of this make sense? Maybe if you could give the masking a go, and submit a PR we can discuss?

jesusdpa1 commented 3 years ago

Hi,

has there been any progress on this issue? we currently are trying to do registration on some of our partial brain acquisition and were wondering if this could be the reason why we are not getting a more precise registration?

Thanks!

adamltyson commented 3 years ago

No progress yet. I don't have the time to work on it yet. Hoping someone can spare a couple of weeks to get this working.

vv-21 commented 2 years ago

Hi, Have there been any updates on this issue? I'd like to register a mouse-brain hemisphere to one of the atlases (e.g. allen 25um), and was wondering if there is a way to do this.

adamltyson commented 2 years ago

Unfortunately not @vv-21. Waiting/hoping for someone to have a bit of free time to tackle this.

JulesScholler commented 2 years ago

49 I am linking my old issue here for reference.

I think I'll give this a try. @adamltyson would you be willing to spend 20 min on zoom with me so that I expose my idea, I'd like to have your feedback on it.

adamltyson commented 2 years ago

@JulesScholler sure, I'll email you.

chrisroat commented 2 years ago

I gave a thumbs up to this issue, and wanted to express interest in it. The description isn't detailed, so I'll explain what would be useful to us. We acquire a single slice of a brain, some 10s or 100um thick. Would it be feasible to register such a slice using the implementations being proposed?

adamltyson commented 2 years ago

Hi @chrisroat, unfortunately this issue relates to 3D registration, but of some volume less than a whole brain (e.g. hemisphere, or some other big "chunk"). If you have a section (unless it's >1mm thick), that's essentially a 2D registration problem that brainreg isn't set up to handle. For 2D data I would recommend ABBA (@NicoKiaru has started looking into linking up ABBA and BrainGlobe).

chrisroat commented 2 years ago

I suppose it's still 3d, since you have to find it's full orientation in the atlas. But I get that just a dozen voxels in z (at 10um res) may not contain a lot of information.

I will check out ABBA, though at first pass the docs look to be serial datasets (not just a single slice), but maybe it would work.

NicoKiaru commented 2 years ago

@chrisroat I didn't test it, but ABBA can somewhat handle 'small sections'. What it will do is just use the middle plane for the registration.

drchrisch commented 2 years ago

Hi @JulesScholler,

referring to your comment

49 I am linking my old issue here for reference.

I think I'll give this a try. @adamltyson would you be willing to spend 20 min on zoom with me so that I expose my idea, I'd like to have your feedback on it.

did you succeed in subregion/hemisphere registration?

adamltyson commented 2 years ago

@drchrisch - as far as I know, this feature hasn't been implemented by anyone yet.

drchrisch commented 2 years ago

Because nobody is really interested (unfortunately, I happen to have a number of hemispheres to work on), it is totally meaningless, it would require rebuilding everything from scratch?

adamltyson commented 2 years ago

It wouldn't require rewriting brainreg, but it isn't trivial. There would be a bit of work to add the necessary code (maybe a day once familiar with the codebase?), but then there may be a lot of parameter optimisation to work with the different input data.

drchrisch commented 2 years ago

It seems there were attemps to include hemisphere registration, but no one really accomplished. Could you suggest another implementation of this supposedly simple registration task?

adamltyson commented 2 years ago

I'm not aware of any tools that specifically support partial images I'm afraid.

drchrisch commented 2 years ago

Ok, I see. Your comment

It wouldn't require rewriting brainreg, but it isn't trivial. There would be a bit of work to add the necessary code (maybe a day once familiar with the codebase?), but then there may be a lot of parameter optimisation to work with the different input data.

suggests that simple masking would not work and fiddling with nifty settings would be needed. Sounds time-consuming even if one would restrict work to just the hemisphere case and exclude other possible sub-regions somewhere between (thick) slice and full brain.

adamltyson commented 2 years ago

I think that's correct, but as I haven't tried it I can't be sure. I would be surprised if masking only would work "out of the box".

adamltyson commented 2 years ago

Thanks to @JulesScholler, there is some progress on this issue. There is now some functionality to register single hemispheres. There is now an additional --brain_geometry flag. The default is full, but you can also choose hemisphere_l or hemisphere_r to specify a single brain hemisphere.

This functionality hasn't been released yet, but if anyone wants to try it out, you can install from github with pip install git+https://github.com/brainglobe/brainreg.

I'd appreciate any user testing, there's likely to lots of further optimisation to be done.

adamltyson commented 1 year ago

May scrap this general issue in favour of creating workflows within napari that allow use of other registration tools with BG atlases.

However, thanks to @JulesScholler the hemisphere registration seems to work well: https://docs.brainglobe.info/brainreg/user-guide#misc-options

adamltyson commented 10 months ago

Closing in favour of https://github.com/brainglobe/brainglobe-registration