Giter VIP home page Giter VIP logo

brainreg's Introduction

Python Version PyPI Wheel Development Status Tests codecov Code style: black

brainreg

brainreg is an update to amap (which is itself a port of the original Java software) to include multiple registration backends, and to support the many atlases provided by brainglobe-atlasapi. It also comes with an optional napari plugin if you'd rather use brainreg with through graphical interface.

Documentation for both the command-line tool and graphical interface can be found here.

For segmentation of bulk structures in 3D space (e.g. injection sites, Neuropixels probes), please see brainglobe-segmentation.

Details

The aim of brainreg is to register the template brain (e.g. from the Allen Reference Atlas) to the sample image. Once this is complete, any other image in the template space can be aligned with the sample (such as region annotations, for segmentation of the sample image). The template to sample transformation can also be inverted, allowing sample images to be aligned in a common coordinate space.

To do this, the template and sample images are filtered, and then registered in a three step process (reorientation, affine registration, and freeform registration). The resulting transform from template to standard space is then applied to the atlas.

Full details of the process are in the original aMAP paper.

An illustrated overview of the registration process

Installation

To install both the command line tool and the napari plugin, run

pip install brainreg[napari]

in your desired Python environment. To only install the command line tool with no GUI (e.g. to run brainreg on an HPC cluster), just run:

pip install brainreg

Installing on macOS

If you are using macOS, please run

conda install -c conda-forge niftyreg

in your environment before installing, to ensure all dependencies are installed.

Command line usage

Basic usage

brainreg /path/to/raw/data /path/to/output/directory -v 5 2 2 --orientation psl

Full command-line arguments are available with brainreg -h, but please get in touch if you have any questions.

Mandatory arguments

  • Path to the directory of the images. This can also be a text file pointing to the files.
  • Output directory for all intermediate and final results.
  • You must also specify the voxel sizes with the -v flag, see specifying voxel size for details.

Atlas

By default, brainreg will use the 25um version of the Allen Mouse Brain Atlas. To use another atlas (e.g. for another species, or another resolution), you must use the --atlas flag, followed by the string describing the atlas, e.g.:

--atlas allen_mouse_50um

To find out which atlases are available, once brainreg is installed, please run brainglobe list. The name of the resulting atlases is the string to pass with the --atlas flag.

Input data orientation

If your data does not match the BrainGlobe default orientation (the origin voxel is the most anterior, superior, left-most voxel), then you must specify the orientation by using the --orientation flag. What follows must be a string in the brainglobe-space "initials" form, to describe the origin voxel.

If the origin of your data (first, top left voxel) is the most anterior, superior, left part of the brain, then the orientation string would be "asl" (anterior, superior, left), and you would use:

--orientation asl

Registration options

To change how the actual registration performs, see registration parameters

Additional options

  • -a or --additional Paths to N additional channels to downsample to the same coordinate space.
  • --sort-input-file If set to true, the input text file will be sorted using natural sorting. This means that the file paths will be sorted as would be expected by a human and not purely alphabetically.
  • --brain_geometry Can be one of full (default) for full brain registration, hemisphere_l for left hemisphere data-set and hemisphere_r for right hemisphere data-set.

Misc options

  • --n-free-cpus The number of CPU cores on the machine to leave unused by the program to spare resources.
  • --debug Debug mode. Will increase verbosity of logging and save all intermediate files for diagnosis of software issues.
  • --save-original-orientation Option to save the registered atlas with the same orientation as the input data.

Visualising results

If you have installed the optional napari plugin, you can use napari to view your data. The plugin automatically fetches the brainglobe-napari-io which provides this functionality. If you have installed only the command-line tool you can still manually install brainglobe-napari-io and follow the steps below.

Sample space

Open napari and drag your brainreg output directory (the one with the log file) onto the napari window.

Various images should then open, including:

  • Registered image - the image used for registration, downsampled to atlas resolution
  • atlas_name - e.g. allen_mouse_25um the atlas labels, warped to your sample brain
  • Boundaries - the boundaries of the atlas regions

If you downsampled additional channels, these will also be loaded. Most of these images will not be visible by default - click the little eye icon to toggle visibility.

Note: If you use a high resolution atlas (such as allen_mouse_10um), then the files can take a little while to load.

GIF illustration of loading brainreg output into napari for visualisation

Seeking help or contributing

We are always happy to help users of our tools, and welcome any contributions. If you would like to get in contact with us for any reason, please see the contact page of our website.

Citing brainreg

If you find brainreg useful, and use it in your research, please let us know and also cite the paper:

Tyson, A. L., Vélez-Fort, M., Rousseau, C. V., Cossell, L., Tsitoura, C., Lenzi, S. C., Obenhaus, H. A., Claudi, F., Branco, T., Margrie, T. W. (2022). Accurate determination of marker location within whole-brain microscopy images. Scientific Reports, 12, 867 doi.org/10.1038/s41598-021-04676-9

Please also cite aMAP (the original pipeline from which this software is based):

Niedworok, C.J., Brown, A.P.Y., Jorge Cardoso, M., Osten, P., Ourselin, S., Modat, M. and Margrie, T.W., (2016). AMAP is a validated pipeline for registration and segmentation of high-resolution mouse brain data. Nature Communications. 7, 1–9. https://doi.org/10.1038/ncomms11879

Lastly, if you can, please cite the BrainGlobe Atlas API that provided the atlas:

Claudi, F., Petrucco, L., Tyson, A. L., Branco, T., Margrie, T. W. and Portugues, R. (2020). BrainGlobe Atlas API: a common interface for neuroanatomical atlases. Journal of Open Source Software, 5(54), 2668, https://doi.org/10.21105/joss.02668

Finally, don't forget to cite the developers of the atlas that you used (e.g. the Allen Brain Atlas)!

brainreg's People

Contributors

adamltyson avatar alessandrofelder avatar dstansby avatar joeziminski avatar julesscholler avatar k-meech avatar noisysky avatar npeschke avatar paddyroddy avatar pre-commit-ci[bot] avatar stephenlenzi avatar willgraham01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brainreg's Issues

vtkplotter removed from PyPI

Hi,

looks like vtkplotter has been removed from PyPI causing this error during brainreg installation.

ERROR: Could not find a version that satisfies the requirement vtkplotter (from imlib).

Thanks,
Michael

Having an error while registering

Dear,

I tried to use the software on windows but I have got an error during the process:

brainreg "E:/dataset" "E:/output" -x 1.38 -y 1.38 -z 1 --atlas allen_mouse_25um
This version of slurmio (0.0.4) is not the most recent version. Please update to v0.0.5 by running: 'pip install slurmio --upgrade' 
INFO:root:Starting logging
2020-07-24 14:19:40 PM - INFO - MainProcess fancylog.py:277 - Starting logging
INFO:root:Not logging multiple processes
2020-07-24 14:19:40 PM - INFO - MainProcess fancylog.py:278 - Not logging multiple processes
INFO:root:Starting registration
2020-07-24 14:19:40 PM - INFO - MainProcess cli.py:210 - Starting registration
Bgatlas_api: None not found locally. Downloading...
Traceback (most recent call last):
  File "d:\sofware\miniconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\sofware\miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\SOFWARE\Miniconda3\Scripts\brainreg.exe\__main__.py", line 7, in <module>
  File "d:\sofware\miniconda3\lib\site-packages\brainreg\cli.py", line 234, in main
    run()
  File "d:\sofware\miniconda3\lib\site-packages\brainreg\cli.py", line 212, in run
    atlas = BrainGlobeAtlas(args.atlas)
  File "d:\sofware\miniconda3\lib\site-packages\bg_atlasapi\bg_atlas.py", line 71, in __init__
    self.download_extract_file()
  File "d:\sofware\miniconda3\lib\site-packages\bg_atlasapi\bg_atlas.py", line 139, in download_extract_file
    utils.retrieve_over_http(self.remote_url, destination_path)
  File "d:\sofware\miniconda3\lib\site-packages\bg_atlasapi\bg_atlas.py", line 126, in remote_url
    maj, min = self.remote_version
  File "d:\sofware\miniconda3\lib\site-packages\bg_atlasapi\bg_atlas.py", line 99, in remote_version
    versions_conf["atlases"][self.atlas_name]
  File "d:\sofware\miniconda3\lib\configparser.py", line 1250, in __getitem__
    if not self._parser.has_option(self._name, key):
  File "d:\sofware\miniconda3\lib\configparser.py", line 885, in has_option
    option = self.optionxform(option)
  File "d:\sofware\miniconda3\lib\configparser.py", line 873, in optionxform
    return optionstr.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

It looks like it can't find the atlas.
I trie to download it using

brainglobe install -a allen_mouse_25um

The installation was successful and everything was saved in:
C:\bin\cygwin\home\myusername\.brainglobe\allen_mouse_25um_v0.3

But running again the registration gave me the same error, making me think that it may not look at the right place to find the Atlas.

BrainReg was installed using pip : pip install brainreg

Benjamin

Tutorial bug: The process cannot access the file because it is being used by another process

Hi I'm trying to run the tutorial for brainreg and kept getting the following error. Could someone take a look and help? Thanks!

Traceback (most recent call last):
File "C:\Users\xinto\anaconda3\envs\brainreg_env\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\xinto\anaconda3\envs\brainreg_env\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\xinto\anaconda3\envs\brainreg_env\Scripts\brainreg.exe_main
.py", line 7, in
File "C:\Users\xinto\anaconda3\envs\brainreg_env\lib\site-packages\brainreg\cli.py", line 207, in main
register(
File "C:\Users\xinto\anaconda3\envs\brainreg_env\lib\site-packages\brainreg\main.py", line 65, in main
run_niftyreg(
File "C:\Users\xinto\anaconda3\envs\brainreg_env\lib\site-packages\brainreg\backend\niftyreg\run.py", line 214, in run_niftyreg
delete_directory_contents(niftyreg_directory)
File "C:\Users\xinto\anaconda3\envs\brainreg_env\lib\site-packages\imlib\general\system.py", line 351, in delete_directory_contents
os.remove(os.path.join(directory, f))
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\xinto\Desktop\test_brain\output\niftyreg\deformation_field.nii'

napari plugin fails to install correctly (linux, python 3.9)

fresh install on Linux 4.15.0-140-generic x86_64

conda env python 3.9

pip install brainreg .[dev]

then simply running napari in the terminal leads to the following error:

WARNING: Could not load the Qt platform plugin "xcb" in "" even though it was found.
14:50:20 WARNING Could not load the Qt platform plugin "xcb" in "" even though it was found.
WARNING: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

14:50:20 WARNING This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

I have also tried to install napari into the same env (pip install napari[all]) but get the same error.

Register individual 2D sections to Atlas

Hi there!

Would it be possible to register individual mouse brain sections to the Atlas?
I have seen that @adamltyson was developing slicereg however as it seems to be based on amap so I am not sure it is still under development or whether it will be included in brainreg.

Putatively, if 4-5 sections of the same brain need to be registered, would it be better to register each of them independently or to register altogether?

Thanks!

CLI -voxel size flag does not maintain orientation

In the code we have this line that says:

Voxel sizes in microns, in the order of data orientation.

However, I tried taking the test brain dataset as per tutorial, which specifies:

-v 50 40 40 --orientation psl

and then rotate this using bg_space to a sagittal orientation "rsp"

mapped_stack = bg.map_stack_to('psl', 'rsp', stack)

Then when I run brainreg with the following command:

brainreg test_brain_rsp brainreg_output_rsp -v 40 40 50 --orientation rsp --atlas allen_mouse_50um

I get an error:

"""
Traceback (most recent call last):
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/concurrent/futures/process.py", line 239, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/imio/load.py", line 459, in load_from_paths_sequence
    volume[:, :, i] = img
ValueError: could not broadcast input array from shape (193,270) into shape (154,270)
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/bin/brainreg", line 8, in <module>
Loading images:   0%|                                                                                                                                                                         | 0/68 [00:00<?, ?plane/s]    sys.exit(main())
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/brainreg/cli.py", line 193, in main
Loading images:   0%|                                                                                                                                                                         | 0/67 [00:00<?, ?plane/s]
    register(
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/brainreg/main.py", line 50, in main
    target_brain = imio.load_any(
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/imio/load.py", line 67, in load_any
    img = load_from_folder(
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/imio/load.py", line 239, in load_from_folder
    return load_image_series(
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/imio/load.py", line 330, in load_image_series
    img = threaded_load_from_sequence(
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/imio/load.py", line 404, in threaded_load_from_sequence
    stack = np.dstack([s.result() for s in stacks])
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/site-packages/imio/load.py", line 404, in <listcomp>
    stack = np.dstack([s.result() for s in stacks])
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/Users/bryant.chhun/anaconda3/envs/brainreg/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
ValueError: could not broadcast input array from shape (193,270) into shape (154,270)

This error is resolved if I change the voxel orientation back to:

brainreg test_brain_rsp brainreg_output_rsp -v 50 40 40 --orientation rsp --atlas allen_mouse_50um

Additionally, the above line outputs an atlas in Coronal orientation. It would be nice if the output files are sliced similarly to the input. But this is not critical and probably worth a separate issue.

Error finding libpng files

I'm trying to run thrhough the brainreg tutorial, and am getting the following error:

Traceback (most recent call last):
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/imlib/general/system.py", line 281, in safe_execute_command
    subprocess.check_call(
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '"/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/bin/nifty_reg/osX/reg_aladin" -ln 6 -lp 5 -flo "brainreg_output/niftyreg/brain_filtered.nii" -ref "brainreg_output/niftyreg/downsampled_filtered.nii" -aff "brainreg_output/niftyreg/affine_matrix.txt" -res "brainreg_output/niftyreg/affine_registered_atlas_brain.nii" -omp 4' died with <Signals.SIGABRT: 6>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/backend/niftyreg/registration.py", line 73, in register_affine
    safe_execute_command(
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/imlib/general/system.py", line 293, in safe_execute_command
    raise SafeExecuteCommandError(
imlib.general.system.SafeExecuteCommandError: 
-------------------------
Process failed:
 dyld[51445]: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/bin/nifty_reg/osX/reg_aladin
  Reason: tried: '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/lib/libpng16.16.dylib' (no such file), '/usr/lib/libpng16.16.dylib' (no such file)
-------------------------

-------------------------
please read the logs at brainreg_output/niftyreg/affine.log and brainreg_output/niftyreg/affine.err
-------------------------
command: "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/bin/nifty_reg/osX/reg_aladin" -ln 6 -lp 5 -flo "brainreg_output/niftyreg/brain_filtered.nii" -ref "brainreg_output/niftyreg/downsampled_filtered.nii" -aff "brainreg_output/niftyreg/affine_matrix.txt" -res "brainreg_output/niftyreg/affine_registered_atlas_brain.nii" -omp 4
-------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dstansby/mambaforge/envs/napari/bin/brainreg", line 8, in <module>
    sys.exit(main())
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/cli.py", line 207, in main
    register(
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/main.py", line 65, in main
    run_niftyreg(
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/backend/niftyreg/run.py", line 82, in run_niftyreg
    brain_reg.register_affine()
  File "/Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/backend/niftyreg/registration.py", line 79, in register_affine
    raise RegistrationError(
brainreg.backend.niftyreg.registration.RegistrationError: Affine registration failed; 
-------------------------
Process failed:
 dyld[51445]: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /Users/dstansby/mambaforge/envs/napari/lib/python3.9/site-packages/brainreg/bin/nifty_reg/osX/reg_aladin
  Reason: tried: '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/lib/libpng16.16.dylib' (no such file), '/usr/lib/libpng16.16.dylib' (no such file)
-------------------------

It looks like this is an issue with the niftyreg binaries that are bundled. I'm on an M1 Mac with macOS 12.2.1, Python 3.10.

Add a GUI

Using napari (as a plugin?). For choosing parameters, running reg and visualising results.

save_original_resolution breaks additional_image_downsample

the save_original_orientation option is a great addition but it redefines atlas

if save_original_orientation:
atlas = imio.load_any(niftyreg_paths.registered_atlas_path).astype(
np.uint32, copy=False
)

and thus, looses the atlas.resolution field which is needed later in additional_image_downsample

save_nii(
downsampled_brain,
atlas.resolution,
tmp_downsampled_brain_path,
)

[BUG] ERROR: Cannot install brainreg==0.0.2 ....

Describe the bug
After I create a new env " Brainreg" and conda activate it. Then I run pip install brainreg

It reported ERROR: Cannot install brainreg==0.0.2, brainreg==0.0.3, brainreg==0.1.1, brainreg==0.1.3, brainreg==0.1.4, brainreg==0.1.6, brainreg==0.1.7, brainreg==0.1.8 and brainreg==0.1.9 because these package versions have conflicting dependencies

To Reproduce

Expected behaviour

Log file

Screenshots
image

  • OS: macOS, M1 CPU
  • Version: 12.0.1
  • Hardware specs: 1 TB flash storage and external 2TB USB DISK

Additional context
Add any other context about the problem here.

Thanks for your time!

Make --orientation mandatory

Very few people will have data that matches the default orientation, so this flag should be mandatory to prevent issues.

No feedback after filtering in the plugin

At least on my system, the command line stops updating after filtering, so you've got no idea when the plugin has finished, or how far it's progressing. Ideally some feedback would appear in the napari GUI as well (in addition to the results appearing #156 ).

how to change the factor of downsample ?

hi adam,
i want to improve the resolution of registered signal channel(in the registration folder), so how to change the factor of downsample? the --affine n steps? or others?
hope for your answer~

Modularized dependencies

Installing brainreg brings in 3.4GB of dependencies, as measured by my virtualenv folder's size. I see many things I don't think(?!) I need for a simple registration - e.g. ipython, jinja2, pyside2, sphinx, and napari. [I could be wrong here, of course.]

Might I suggest verifying what is needed, and perhaps having separate extras for some of this functionality? This could leave the core "pip install brainreg" to bring in a minimal set of dependencies to run registration.

registered brain is shrunk compared to brain

Hello
I run brainreg, both alone and as part of cellfinder to register a brain (orientation ipr) to the allen 25um atlas. While the atlas is properly aligned, it doesn't fit the brain properly (it seems a bit shrunk). See images below.

Do you have suggestions on how to fix/improve on this?

From standalone brainreg run:
immagine
immagine
immagine

From cellfinder run:
immagine

Here is the .yaml of the conda env I used (converted to txt)
cellfinder.txt
here is the log file for the standalone brainreg run:
brainreg_2022-05-11_15-17-35.log
and the log file for the cellfinder run:
cellfinder_2022-05-11_17-10-23.log

Seperate preprocessing from registration

Currently the preprocessing is fixed, and based upon serial2p datasets. The preprocessing should be a seperate step, potentially leveraging existing napari plugins.

Options could include:

  • No preprocessing (load preprocessed data)
  • Existing filters for serial2p datasets
  • LSFM-specific filters - @horsto did you manage to get brainreg working on your lightsheet data?
  • fMOST - @noisysky - it would be great to bring your fMOST preprocessing steps into brainreg/napari somehow so that others can use it on their data.

Document output files

All brainreg output files are not completely clear what they are, this should be documented.

Save atlas in the same orientation as input data

The registered atlas file is always saved in the same orientation. I understand this can be useful for some applications but in the most common case where you want to analyse your data by overlaying the atlas onto the data it is quite cumbersome because one has to track the input orientation throughout the analysis pipeline.

Is there a possibility to save the registered atlas in the same orientation as the input data?

Thanks for your help and this amazing work :).

Tool to check for orientation

Not really an issue but more of a question.

Is there a practical way to check the orientation of the data in a user friendly manner? I usually use BG-space to apply a transformation and then display the data along the Atlas but it requires some coding. I found out that the most difficult part of the registration for users is actually finding the orientation because if you mess up then the registration result is bad and people will start tweaking the parameters without realizing that the data was not aligned correctly.

Thanks and keep up the amazing work :).

confocal serial images

Hi, I am currently planning to try this registration tool in the confocal images of serial slices.
Differ to serial 2p microscopy, the brain slices were mounted after scanning. Therefore, the slice might not be perfectly centralized and will have different angles rotation.

I've tried to simulate the experimental results by using test_file serial images with some artificial shifting and rotating. but seems the registration algorithm does not annotate correctly. Is there any way to circumvent this issue or do the correction in the program?

image
image

Check for corrupted files

  • Identify potential corrupted files before proceeding with registration (based on file size)
  • Identify corrupted files on loading (and report to user), exit gracefully
  • Option to continue anyway (e.g. if a small number are affected) - copy previous section?

cc @FedeClaudi

Sub-brain region registration

Hi there, it's me again!

Any plan on allowing to register a single hemisphere or full brain without olfactory bulb for example?

If you did not implement anything yet, I might give it a try because it is often the case that we have partial brains and it becomes really cumbersome to register them if possible at all.

I already have a plan in mind, however I am open to any suggestions.

Cheers,
Jules

error of registration

the data has been registrated successfully. but recently, when the data is registrated, there is error like this.

2021-06-01 16:16:50 PM - INFO - MainProcess run.py:56 - Registering
2021-06-01 16:16:50 PM - INFO - MainProcess run.py:76 - Starting affine registration
Traceback (most recent call last):
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\imlib\general\system.py", line 281, in safe_execute_command
subprocess.check_call(
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin -ln 6 -lp 5 -flo G:\ms20output_TIFF\output1\registration\niftyreg\brain_filtered.nii -ref G:\ms20output_TIFF\output1\registration\niftyreg\downsampled_filtered.nii -aff G:\ms20output_TIFF\output1\registration\niftyreg\affine_matrix.txt -res G:\ms20output_TIFF\output1\registration\niftyreg\affine_registered_atlas_brain.nii -omp 46' returned non-zero exit status 3221225477.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\backend\niftyreg\registration.py", line 73, in register_affine
safe_execute_command(
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\imlib\general\system.py", line 293, in safe_execute_command
raise SafeExecuteCommandError(
imlib.general.system.SafeExecuteCommandError:

Process failed:

[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin]
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin] Command line:
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin]
c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin -ln 6 -lp 5 -flo G:\ms20output_TIFF\output1\registration\niftyreg\brain_filtered.nii -ref G:\ms20output_TIFF\output1\registration\niftyreg\downsampled_filtered.nii -aff G:\ms20output_TIFF\output1\registration\niftyreg\affine_matrix.txt -res G:\ms20output_TIFF\output1\registration\niftyreg\affine_registered_atlas_brain.nii -omp 46
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin]
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin] OpenMP is used with 46 thread(s)
[reg_aladin_sym] Parameters
[reg_aladin_sym] Platform: cpu_platform
[reg_aladin_sym] Reference image name: G:\ms20output_TIFF\output1\registration\niftyreg\downsampled_filtered.nii
[reg_aladin_sym] 1742x1120x1489 voxels
[reg_aladin_sym] 0.01x0.01x0.01 mm
[reg_aladin_sym] Floating image name: G:\ms20output_TIFF\output1\registration\niftyreg\brain_filtered.nii
[reg_aladin_sym] 1320x800x1140 voxels
[reg_aladin_sym] 0.01x0.01x0.01 mm
[reg_aladin_sym] Maximum iteration number: 5
[reg_aladin_sym] (10 during the first level)
[reg_aladin_sym] Percentage of blocks: 50 %
[reg_aladin_sym] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


please read the logs at G:\ms20output_TIFF\output1\registration\niftyreg\affine.log and G:\ms20output_TIFF\output1\registration\niftyreg\affine.err

command: c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin -ln 6 -lp 5 -flo G:\ms20output_TIFF\output1\registration\niftyreg\brain_filtered.nii -ref G:\ms20output_TIFF\output1\registration\niftyreg\downsampled_filtered.nii -aff G:\ms20output_TIFF\output1\registration\niftyreg\affine_matrix.txt -res G:\ms20output_TIFF\output1\registration\niftyreg\affine_registered_atlas_brain.nii -omp 46

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\CIBR-ImFacility-WS1\anaconda3\envs\cellfinder\Scripts\cellfinder.exe_main
.py", line 7, in
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\cellfinder\main.py", line 53, in main
register(
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\main.py", line 65, in main
run_niftyreg(
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\backend\niftyreg\run.py", line 77, in run_niftyreg
brain_reg.register_affine()
File "c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\backend\niftyreg\registration.py", line 79, in register_affine
raise RegistrationError(
brainreg.backend.niftyreg.registration.RegistrationError: Affine registration failed;

Process failed:

[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin]
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin] Command line:
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin]
c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin -ln 6 -lp 5 -flo G:\ms20output_TIFF\output1\registration\niftyreg\brain_filtered.nii -ref G:\ms20output_TIFF\output1\registration\niftyreg\downsampled_filtered.nii -aff G:\ms20output_TIFF\output1\registration\niftyreg\affine_matrix.txt -res G:\ms20output_TIFF\output1\registration\niftyreg\affine_registered_atlas_brain.nii -omp 46
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin]
[c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin] OpenMP is used with 46 thread(s)
[reg_aladin_sym] Parameters
[reg_aladin_sym] Platform: cpu_platform
[reg_aladin_sym] Reference image name: G:\ms20output_TIFF\output1\registration\niftyreg\downsampled_filtered.nii
[reg_aladin_sym] 1742x1120x1489 voxels
[reg_aladin_sym] 0.01x0.01x0.01 mm
[reg_aladin_sym] Floating image name: G:\ms20output_TIFF\output1\registration\niftyreg\brain_filtered.nii
[reg_aladin_sym] 1320x800x1140 voxels
[reg_aladin_sym] 0.01x0.01x0.01 mm
[reg_aladin_sym] Maximum iteration number: 5
[reg_aladin_sym] (10 during the first level)
[reg_aladin_sym] Percentage of blocks: 50 %
[reg_aladin_sym] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


please read the logs at G:\ms20output_TIFF\output1\registration\niftyreg\affine.log and G:\ms20output_TIFF\output1\registration\niftyreg\affine.err

command: c:\users\cibr-imfacility-ws1\anaconda3\envs\cellfinder\lib\site-packages\brainreg\bin\nifty_reg\win64\reg_aladin -ln 6 -lp 5 -flo G:\ms20output_TIFF\output1\registration\niftyreg\brain_filtered.nii -ref G:\ms20output_TIFF\output1\registration\niftyreg\downsampled_filtered.nii -aff G:\ms20output_TIFF\output1\registration\niftyreg\affine_matrix.txt -res G:\ms20output_TIFF\output1\registration\niftyreg\affine_registered_atlas_brain.nii -omp 46

Add support for macOS

Now NityReg is on conda, we should be able to more easily support macOS. This would require:

  • Supporting system installations of NityReg (rather than the packaged binaries)
  • Document conda installation of NiftyReg (and maybe brainreg)
  • Add tests for macOS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.