brainreg icon indicating copy to clipboard operation
brainreg copied to clipboard

Support registration of partial images

Open adamltyson opened this issue 4 years ago • 24 comments

As with amap

adamltyson avatar Jul 14 '20 12:07 adamltyson

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.

wudustan avatar Mar 18 '21 14:03 wudustan

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 avatar Mar 18 '21 17:03 adamltyson

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.

adamltyson avatar Mar 18 '21 17:03 adamltyson

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

wudustan avatar Mar 25 '21 16:03 wudustan

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:

  • Only right hemisphere - do nothing
  • Only left hemisphere - Add atlas image width / 2 (in mm) to deformation_field_2.tiff
  • For other, arbitrary volumes, do something similar, but in whichever of 3 dimensions are needed.

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

adamltyson avatar Mar 26 '21 08:03 adamltyson

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!

jesusdpa1 avatar Apr 15 '21 21:04 jesusdpa1

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.

adamltyson avatar Apr 16 '21 08:04 adamltyson

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.

vv-21 avatar Nov 23 '21 14:11 vv-21

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

adamltyson avatar Nov 23 '21 14:11 adamltyson

#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.

JulesScholler avatar Dec 07 '21 12:12 JulesScholler

@JulesScholler sure, I'll email you.

adamltyson avatar Dec 07 '21 12:12 adamltyson

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?

chrisroat avatar Jan 10 '22 13:01 chrisroat

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).

adamltyson avatar Jan 10 '22 16:01 adamltyson

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.

chrisroat avatar Jan 10 '22 19:01 chrisroat

@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.

NicoKiaru avatar Jan 13 '22 10:01 NicoKiaru

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?

drchrisch avatar Feb 14 '22 09:02 drchrisch

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

adamltyson avatar Feb 14 '22 09:02 adamltyson

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?

drchrisch avatar Feb 14 '22 09:02 drchrisch

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.

adamltyson avatar Feb 14 '22 09:02 adamltyson

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?

drchrisch avatar Feb 14 '22 10:02 drchrisch

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

adamltyson avatar Feb 14 '22 10:02 adamltyson

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.

drchrisch avatar Feb 14 '22 10:02 drchrisch

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 avatar Feb 14 '22 10:02 adamltyson

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 avatar Jul 25 '22 16:07 adamltyson

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 avatar Jan 10 '23 14:01 adamltyson

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

adamltyson avatar Nov 24 '23 16:11 adamltyson