This repository has been archived by the owner on Oct 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cellfinder -> brainrender points transformation
- Loading branch information
1 parent
1b9ccd0
commit bb220e6
Showing
9 changed files
with
4,113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
[![Python Version](https://img.shields.io/pypi/pyversions/neuro.svg)](https://python.org) | ||
[![PyPI](https://img.shields.io/pypi/v/neuro.svg)](https://pypi.org/project/neuro) | ||
[![Wheel](https://img.shields.io/pypi/wheel/neuro.svg)](https://pypi.org/project/neuro) | ||
[![Development Status](https://img.shields.io/pypi/status/neuro.svg)](https://github.com/SainsburyWellcomeCentre/neuro) | ||
[![Travis](https://img.shields.io/travis/com/SainsburyWellcomeCentre/neuro?label=Travis%20CI)]( | ||
https://travis-ci.com/SainsburyWellcomeCentre/neuro) | ||
[![Coverage Status](https://coveralls.io/repos/github/SainsburyWellcomeCentre/neuro/badge.svg?branch=master)](https://coveralls.io/github/SainsburyWellcomeCentre/neuro?branch=master) | ||
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) | ||
|
||
|
||
# neuro | ||
Visualisation and analysis of brain imaging data |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
""" | ||
Converts point positions from cellfinder coordinates to brainrender | ||
N.B. This is currently specific to coronal images, with the origin at the most | ||
caudal, ventral left point. The default is also for 10um voxel spacing. | ||
""" | ||
|
||
import argparse | ||
import imlib.IO.cells as cells_io | ||
from imlib.misc import check_positive_float, check_positive_int | ||
|
||
|
||
def run( | ||
cells_file, | ||
output_filename, | ||
pixel_size_x=10, | ||
pixel_size_y=10, | ||
pixel_size_z=10, | ||
max_z=13200, | ||
key="df", | ||
): | ||
print(f"Converting file: {cells_file}") | ||
cells = cells_io.get_cells(cells_file) | ||
cells = cells_io.cells_to_dataframe(cells) | ||
|
||
cells["x"] = cells["x"] * pixel_size_x | ||
cells["y"] = cells["y"] * pixel_size_y | ||
cells["z"] = cells["z"] * pixel_size_z | ||
|
||
cells.columns = ["z", "y", "x", "type"] | ||
|
||
cells["x"] = max_z - cells["x"] | ||
|
||
print(f"Saving to: {output_filename}") | ||
cells.to_hdf(output_filename, key=key, mode="w") | ||
|
||
print("Finished") | ||
|
||
|
||
def get_parser(): | ||
parser = argparse.ArgumentParser( | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter | ||
) | ||
parser.add_argument( | ||
dest="cells_file", | ||
type=str, | ||
help="Cellfinder cells file to be converted", | ||
) | ||
parser.add_argument( | ||
dest="output_filename", | ||
type=str, | ||
help="Output filename. Should end with '.h5'", | ||
) | ||
|
||
parser.add_argument( | ||
"-x", | ||
"--x-pixel-size", | ||
dest="x_pixel_size", | ||
type=check_positive_float, | ||
default=10, | ||
help="Pixel_size that the cells are defined in.", | ||
) | ||
parser.add_argument( | ||
"-y", | ||
"--y-pixel-size", | ||
dest="y_pixel_size", | ||
type=check_positive_float, | ||
default=10, | ||
help="Pixel_size that the cells are defined in.", | ||
) | ||
parser.add_argument( | ||
"-z", | ||
"--z-pixel-size", | ||
dest="z_pixel_size", | ||
type=check_positive_float, | ||
default=10, | ||
help="Pixel_size that the cells are defined in.", | ||
) | ||
parser.add_argument( | ||
"--max-z", | ||
dest="max_z", | ||
type=check_positive_int, | ||
default=13200, | ||
help="Maximum z extent of the atlas", | ||
) | ||
parser.add_argument( | ||
"--hdf-key", | ||
dest="hdf_key", | ||
type=str, | ||
default="df", | ||
help="hdf identifier ", | ||
) | ||
return parser | ||
|
||
|
||
def main(): | ||
args = get_parser().parse_args() | ||
run( | ||
args.cells_file, | ||
args.output_filename, | ||
pixel_size_x=args.x_pixel_size, | ||
pixel_size_y=args.y_pixel_size, | ||
pixel_size_z=args.z_pixel_size, | ||
max_z=args.max_z, | ||
key=args.hdf_key, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.