Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
456 commits
Select commit Hold shift + click to select a range
dbcf5fd
using scipy zoom to rescale atlas
eddyod Sep 17, 2022
ea96890
Have the full zoomed sagittal boundaries available
eddyod Sep 19, 2022
fb2114d
Fixed shapes of sagittal output
eddyod Sep 19, 2022
0fe3af1
Fixed shapes of sagittal output #1
eddyod Sep 19, 2022
34bc110
Fixed shapes of sagittal output #2
eddyod Sep 19, 2022
8742afe
Removed rotate and flip from final step
eddyod Sep 19, 2022
043ec5c
Corrected values in float vs int in output
eddyod Sep 19, 2022
f2e9bd7
Updated dir on mesh creator
eddyod Sep 19, 2022
4385597
Changed path to atlas data in create alt atlas
eddyod Sep 21, 2022
eb4ca35
Added argparse to create alt atlas
eddyod Sep 21, 2022
bf1f950
Added argparse to create alt atlas fixed paths #1
eddyod Sep 21, 2022
112f34f
Updated requirements.txt file from pip freeze
eddyod Sep 23, 2022
58c4f03
Updated the instructions for running the czi to neuroglancer process
eddyod Sep 23, 2022
1fbfe49
Updated the instructions for running the czi to neuroglancer process …
eddyod Sep 23, 2022
3670bc9
update
madwilliam Sep 28, 2022
847ea5f
updates
madwilliam Sep 28, 2022
e64fd21
udpate
madwilliam Sep 30, 2022
ff97b5e
Added a script to generate annotations as a precomputed image layer
eddyod Oct 1, 2022
89e2190
updates
madwilliam Oct 3, 2022
ce949e5
Bulk file renaming to support processing of DK84 brain
drinehart1 Oct 4, 2022
c3b3c39
Yoav added a directory called "reorganize documentation"
yoavfreund Oct 4, 2022
7753e95
reorganizing file locations in docs
yoavfreund Oct 5, 2022
621df1f
Update high.level.overall.design.of.projects.md
yoavfreund Oct 5, 2022
b3a5446
Update high.level.overall.design.of.projects.md
yoavfreund Oct 5, 2022
e3a4260
Update high.level.overall.design.of.projects.md
yoavfreund Oct 5, 2022
935a3f9
Update high.level.overall.design.of.projects.md
yoavfreund Oct 5, 2022
2672af4
Update high.level.overall.design.of.projects.md
yoavfreund Oct 5, 2022
ddf96ce
Update high.level.overall.design.of.projects.md
yoavfreund Oct 5, 2022
52c25f0
Update high.level.overall.design.of.projects.md
yoavfreund Oct 5, 2022
2069b1a
Update Reorganization_Plan.md
yoavfreund Oct 5, 2022
958506b
Update Reorganization_Plan.md
yoavfreund Oct 5, 2022
7de7556
Update Reorganization_Plan.md
yoavfreund Oct 5, 2022
156a51d
added testing to the reorganization plan
yoavfreund Oct 5, 2022
61bb815
fixed Reorganization plan.md
yoavfreund Oct 5, 2022
6f0f9cc
fixed Reorganization plan.md
yoavfreund Oct 5, 2022
46917bc
update
madwilliam Oct 8, 2022
8f9ea8b
update
madwilliam Oct 8, 2022
43df59b
fixed logging, cleaned up
drinehart1 Oct 10, 2022
06cc2cc
cleaned up re:Java and FileLogger
drinehart1 Oct 10, 2022
eff3d54
Merge remote-tracking branch 'origin/development' into development
drinehart1 Oct 10, 2022
dc76535
added docstring
drinehart1 Oct 10, 2022
3bbb571
Added some try/except on image opening. Also deleted useless masking …
eddyod Oct 11, 2022
304d3e4
Merge branch 'development' of github.com:/ActiveBrainAtlas2/preproces…
drinehart1 Oct 11, 2022
89b861d
added comment hint on image rotation if image dimensions don't match …
drinehart1 Oct 11, 2022
f4235dd
removed Java environment variable reference
drinehart1 Oct 11, 2022
992ea08
assign file logging path to env variable (easier to access from other…
drinehart1 Oct 11, 2022
6a2ef6e
pull file logging path from env variable - when instantiating CZI cla…
drinehart1 Oct 11, 2022
af7630d
Added sphinx to development branch
eddyod Oct 12, 2022
9f606aa
Added requirements for docs
eddyod Oct 12, 2022
d5f80da
Added requirements for docs set version aicsimageio==3.2.1
eddyod Oct 12, 2022
f8db41c
Added a script to run elastix and the parameter files
eddyod Oct 13, 2022
756500f
Added a script to run elastix and the parameter files updated script
eddyod Oct 13, 2022
02b95ef
Added a script to run elastix and the parameter files updated script #2
eddyod Oct 13, 2022
688633a
Added a script to run elastix and the parameter files updated script #3
eddyod Oct 13, 2022
6d742d5
Added a script to run elastix and the parameter files updated script #4
eddyod Oct 13, 2022
a4c28c3
Added create image stack
eddyod Oct 13, 2022
b66fb12
Added create image stack added tqdm
eddyod Oct 13, 2022
3a3919e
Added create image stack added uint 16
eddyod Oct 13, 2022
8cac305
Removed the low number of iterations in elastix
eddyod Oct 14, 2022
ca5406a
module docs
madwilliam Oct 14, 2022
ada7db4
Took out the bftools and java checks in pipeline.py
eddyod Oct 15, 2022
181f492
Increased batch size and workers in mask trainer
eddyod Oct 17, 2022
f377a5d
Reset works and batch to 1 and took out train an epoch
eddyod Oct 17, 2022
8b87bb0
Reset to use train one epoch
eddyod Oct 17, 2022
45cfd49
Reset to use simple loop
eddyod Oct 17, 2022
f146703
Reset to use simple loop added more debugging
eddyod Oct 17, 2022
f4c5a31
Reset to use simple loop added more debugging #1
eddyod Oct 17, 2022
50fd665
Added new directive to fix file system error in mask trainer
eddyod Oct 17, 2022
0ef5316
updates
madwilliam Oct 17, 2022
35286df
Merge branch 'master' of github.com:ActiveBrainAtlas2/preprocessing-p…
madwilliam Oct 17, 2022
9e2f7c2
Added loss chart to mask trainer
eddyod Oct 18, 2022
eee2968
Moved sphinx documentation to docs.sphinx
eddyod Oct 19, 2022
2f4a380
Updated the Sphinx docs with new documentation
eddyod Oct 19, 2022
389edbf
Moved controllers and models to abakit
eddyod Oct 26, 2022
024d3c6
Merged cell extractor from master into development
eddyod Oct 27, 2022
dc31d64
Put controllers and models back into pipeline
eddyod Oct 27, 2022
2842d42
auto doc of docstrings with sphinx
drinehart1 Oct 27, 2022
80d09b6
Merge branch 'development' of github.com:/ActiveBrainAtlas2/preproces…
drinehart1 Oct 27, 2022
bec8ad5
Merge branch 'development' into master
eddyod Oct 28, 2022
29bc997
Updated the create metric process. It checks if there is already a value
eddyod Oct 28, 2022
5615c38
Initialized the variable data in Czi manager
eddyod Oct 28, 2022
2c085ec
Changed scale factor to int in tiff extractor
eddyod Oct 28, 2022
83dbbb6
Changed scaling factor in tiff extractor to the float downsampling
eddyod Oct 28, 2022
99e9f46
Added more excepts to open tif
eddyod Oct 28, 2022
b223beb
Added a return after reading exception on tiff extractor
eddyod Oct 28, 2022
dd01106
Added a return after reading exception on tiff extractor and a tab break
eddyod Oct 28, 2022
20db50c
Added a return after reading exception on tiff extractor and a tab break
eddyod Oct 28, 2022
22c78cc
Added a return after reading exception on tiff extractor and a space …
eddyod Oct 28, 2022
c53b884
Added scene and channel to error message
eddyod Oct 28, 2022
757f2f7
Added scene and channel to error message including the tif file name
eddyod Oct 28, 2022
6ec132f
Added scene and channel to error message including the tif file name …
eddyod Oct 28, 2022
ce36153
Fixed scaling factor in image cleaner
eddyod Oct 28, 2022
3434384
Added a delete and create directory for logpath in create metrics
eddyod Oct 31, 2022
f4e8711
Removed the rmtree from create metrics
eddyod Oct 31, 2022
5d22188
Manual alignment tool is working as expected
eddyod Nov 1, 2022
f5a1ae8
Updated the # of iterations in the elastix transformation to 2000 as
eddyod Nov 1, 2022
dd72655
Fixed scaling factor in create neuroglancer process
eddyod Nov 2, 2022
5d2022f
Fixed z resolution in get scales
eddyod Nov 2, 2022
cd8f78b
Set step 5, part 1 to receive nanometers
eddyod Nov 2, 2022
7e1418d
augmented doc string with more verbosity
drinehart1 Nov 2, 2022
23ffbe7
augmented doc string with more verbosity
drinehart1 Nov 2, 2022
5de41e8
Moved # elastix iterations to static variable
eddyod Nov 3, 2022
3e41db8
Added a method to create section images for the database portal
eddyod Nov 3, 2022
2afc81d
Updated requirements.txt to python 3.10
ActiveBrainAtlas Nov 3, 2022
0dd742b
Added more try except to read_image
eddyod Nov 3, 2022
c7c2922
Added more try except to read_image and more
eddyod Nov 3, 2022
9224199
Updated try/except in read_image
eddyod Nov 4, 2022
ae8d9a6
Added if clause to create png files
eddyod Nov 4, 2022
293b4c0
moved from lib folder as references to this file came from atlas
drinehart1 Nov 4, 2022
649b893
functions moved to relevant modules in utilities folder
drinehart1 Nov 4, 2022
47f6a8a
reorganized functions to de-duplicate and consolidate
drinehart1 Nov 4, 2022
60bedcb
added more verbose docstrings to all classes
drinehart1 Nov 4, 2022
0a5ba31
Merge remote-tracking branch 'origin/master'
drinehart1 Nov 5, 2022
6ea81cb
Upped the sql timeout to 24hrs
eddyod Nov 5, 2022
e055055
Forced width and height to be ints in get rotation center
eddyod Nov 5, 2022
440b24a
Turned down the min file size for test dir
eddyod Nov 7, 2022
d7540e9
Turned down the min file size for test dir #2
eddyod Nov 7, 2022
a864dd9
Added math to shell tools import
eddyod Nov 7, 2022
1722c24
commended out imports - documentation
drinehart1 Nov 7, 2022
f51c57c
modified import path for SQL controller
drinehart1 Nov 7, 2022
18aa3e7
augmented class for documentation
drinehart1 Nov 7, 2022
0b368a9
documentation formatting edits
drinehart1 Nov 7, 2022
b4229ea
documentation formatting edits
drinehart1 Nov 7, 2022
82c7ac0
documentation formatting edits
drinehart1 Nov 7, 2022
4d50148
Added more logging to extract process
eddyod Nov 8, 2022
f8bbce4
Reverting sqlcontroller init to less arguments
eddyod Nov 8, 2022
830e5e0
Reverting sqlcontroller init to less arguments update 1
eddyod Nov 8, 2022
bf3f425
Reverting sqlcontroller init to less arguments update 2
eddyod Nov 8, 2022
b556f7b
Organized the host,schema, user, password thing.
eddyod Nov 8, 2022
5af1b17
Fixed indentation problem on tiff extractor
eddyod Nov 8, 2022
3e84f53
Moved dir=model to database_model
eddyod Nov 10, 2022
219cde1
added docstrings and minor annotations
drinehart1 Nov 10, 2022
2aa47cd
Added try except to read image
eddyod Nov 10, 2022
7b4f150
Added try except to read image more info
eddyod Nov 10, 2022
c0c835a
Added a audit tree of necessary files to run the pipeline
eddyod Nov 11, 2022
787c348
1. Move non-essential directories out of pipeline.
eddyod Nov 11, 2022
18a0a65
Added more documentation
eddyod Nov 11, 2022
116e49f
Added opencv and pandas to requirements for docs
eddyod Nov 11, 2022
c8bc6ea
Removed get_cpus in shell_tools. Redundant
eddyod Nov 11, 2022
19d4afa
Added scikit-image to requirements for docs
eddyod Nov 11, 2022
0c86070
Added traitlets to requirements for docs
eddyod Nov 11, 2022
510d531
Added autodoc_mock_imports to conf.py
eddyod Nov 11, 2022
98e273f
Added matplotlib to docs requirements
eddyod Nov 11, 2022
f81906e
Added SimpleITK to docs requirements
eddyod Nov 11, 2022
3abc992
Added IPython to docs requirements
eddyod Nov 11, 2022
2b11b9e
Updated lots of the docstrings and removed redundant methods.
eddyod Nov 14, 2022
ab90b1b
sphinx doc generation for pipeline
drinehart1 Nov 14, 2022
6021594
Merge remote-tracking branch 'origin/master'
drinehart1 Nov 14, 2022
80fabd6
Yoav Added output from pyflakes
yoavfreund Nov 15, 2022
6e6355d
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
b621338
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
caea70c
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
a545023
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
4995b42
Removed a lot of unneeded methods.
eddyod Nov 15, 2022
b2a76f7
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
0b2c050
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
510b374
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
5594c61
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
32fd53c
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
39bc463
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
861d521
sphinx doc generation for pipeline
drinehart1 Nov 15, 2022
bb51e68
Moved registration dir up to base.
eddyod Nov 16, 2022
8ad1a16
Cleaning up the Neuroglancer classes
eddyod Nov 16, 2022
b16325d
HighLevelDoc added
yoavfreund Nov 17, 2022
4b4c96d
More cleaning and documenting
eddyod Nov 17, 2022
7d08ae0
Created an archive dir in the top level and copied all pipeline code.
eddyod Nov 17, 2022
cbd70ab
Added all necessary sphinx RST docs. Just need to finish docstrings
eddyod Nov 17, 2022
20be39b
Trimmed down the entire pipeline directory with new production ready
eddyod Nov 18, 2022
d5aaa6f
Took out explicit return in getimagesize
eddyod Nov 18, 2022
fc3f494
Took out explicit return in getimagesize #2
eddyod Nov 18, 2022
bd964c6
Took out explicit return in getimagesize #3
eddyod Nov 18, 2022
263f774
Took out explicit return in getimagesize #4
eddyod Nov 18, 2022
7ada960
Updated mock imports in sphinx/conf
eddyod Nov 18, 2022
588caf4
1. Moved lib to image_manipulation.
eddyod Nov 18, 2022
63fc07f
Moved lib to image_manipulation
eddyod Nov 18, 2022
9275933
1. Created a src directory
eddyod Nov 18, 2022
e8748f4
Updated the path in docs/conf.py
eddyod Nov 18, 2022
c869cab
Added more mock imports to sphinx conf
eddyod Nov 19, 2022
416bb81
Added more mock imports to sphinx conf: igneous
eddyod Nov 19, 2022
b8b97f3
Took out parameter casting in neuroglancer manager
eddyod Nov 19, 2022
d0b0aeb
Took out parameter casting in neuroglancer manager part 2
eddyod Nov 19, 2022
6cce5a6
Added more mock imports to sphinx conf: torchvision
eddyod Nov 19, 2022
5470b4b
Removed file_log, created scripts dir
eddyod Nov 21, 2022
42e99ed
Removed more unecessary methods and added more documentation
eddyod Nov 21, 2022
31e5c88
Added scripts dir and files to git
eddyod Nov 21, 2022
33f497a
Created a static variable for number of iterations for registration
eddyod Nov 23, 2022
74a5efa
Created a static variable for number of iterations for registration r…
eddyod Nov 23, 2022
f62f516
Fixed align elastix
eddyod Nov 23, 2022
74bf322
Fixed align elastix, put original method back in.
eddyod Nov 23, 2022
1943527
added debugging info to create metrics
eddyod Nov 23, 2022
d95fd05
Fixed path problem in create metrics
eddyod Nov 23, 2022
5e4cbbc
Updated the num iterations for create metrics and simplified
eddyod Nov 27, 2022
16d331e
Added get torch device for masking model
eddyod Nov 27, 2022
b25969e
Put in debugging for prep creator
eddyod Nov 27, 2022
cd563c5
Put in debugging for prep creator part 2
eddyod Nov 27, 2022
9d83cb2
Added notebooks dir
eddyod Nov 28, 2022
5ccbdc3
Added a doc for the software installation.
eddyod Nov 28, 2022
17b35e2
Added a title for sofware installation
eddyod Nov 28, 2022
32b89c0
Added a title for sofware installation made it shorter
eddyod Nov 28, 2022
9e9238a
Fixed a bug with scene number being used instead of scene_index
eddyod Nov 28, 2022
ac2589c
Fixed a bug with scene number being used instead of scene_index more …
eddyod Nov 28, 2022
cab024d
Fixed the get sections in create PNG method
eddyod Nov 29, 2022
c653bfa
Added a PNG section creator for the database portal viewing.
eddyod Nov 29, 2022
b74e2c3
Renamed some methods to be more obvious
eddyod Nov 30, 2022
a9dbe33
Added a script to generate an image stack.
eddyod Nov 30, 2022
460f704
Added the mask trainer to src/masking.
eddyod Dec 11, 2022
75661e3
Took out some debugging stuff in the masking scripts
eddyod Dec 11, 2022
d965bde
Updated the software installation docs
eddyod Dec 12, 2022
cc74c91
Updated some paths in the documentation
eddyod Dec 12, 2022
7a353f3
Removed progress lookup class as it never worked well and isn't used
eddyod Dec 12, 2022
ff05463
Adding script to do registration for a downsampled volume to the Alle…
eddyod Dec 15, 2022
8d275f2
Fixed path for registration in create image stack
eddyod Dec 15, 2022
279cfb8
Fixed path for registration in create image stack part 2
eddyod Dec 15, 2022
3e14a5f
Added a method to rotate and flip the allen atlas to look like ours
eddyod Dec 15, 2022
12b8f27
Added a method to rotate and flip the allen atlas to look like ours f…
eddyod Dec 15, 2022
ae8ab8b
Added a image stack to allen brain registration program.
eddyod Dec 15, 2022
e5db9b0
Removed progress manager from documentation as it is deprecated.
eddyod Dec 16, 2022
9e26054
Reset scaling factor to 32 to redo DK52
eddyod Dec 18, 2022
f5eae60
Added a elastix file parser script
eddyod Dec 19, 2022
d34ee8c
Added in the old transform elastix creation method
eddyod Dec 19, 2022
57f7eae
Reverted create pipeline
eddyod Dec 20, 2022
705ba5a
Added a 2nd iteration to the alignment process
eddyod Jan 12, 2023
64f047b
Took out GPU in creating masks as it is unnecessary
eddyod Jan 17, 2023
b644597
Added more verbose loggging to scan run controller
eddyod Jan 17, 2023
5a5f35c
Fixed update scan run controller
eddyod Jan 17, 2023
7ca209e
Defined img in read image early on in the method
eddyod Jan 18, 2023
d6d5893
Defined img in read image early on in the method with a better error …
eddyod Jan 18, 2023
28588e9
Added create metrics to both alignment iterations
eddyod Jan 18, 2023
bd5d6f4
Added create metrics to both alignment iterations to create_pipeline
eddyod Jan 18, 2023
f7894f3
Added iteration value to update metric row
eddyod Jan 18, 2023
578a7ba
Added iteration value to update metric row. Added correct input path …
eddyod Jan 18, 2023
f1eeb4a
Added more debugging info to alignment process
eddyod Jan 21, 2023
8c33eb4
Still working on the alignment iterations
eddyod Jan 23, 2023
1b150e6
Took out the hist equalization method temp
eddyod Jan 23, 2023
8c1ff42
Updated the limit to 100 on the CLAHE in utilities mask
eddyod Jan 23, 2023
d3fcf41
Updated the limit to 100 on the CLAHE in utilities mask, set it to 80…
eddyod Jan 23, 2023
9f4a577
changed clahe to 60
eddyod Jan 23, 2023
28562bf
Simplifying the registration process
eddyod Jan 25, 2023
5f5f18f
Cleaned up alignment process
eddyod Jan 25, 2023
46d4ad9
Updated create mesh script to work with different scales
eddyod Jan 30, 2023
a1e4f92
Updated create mesh script to work with different scales update #2
eddyod Jan 30, 2023
36e645e
Fixed boolean array in create mesh
eddyod Jan 30, 2023
bb10365
Changed iteration to range from list items in create mesh
eddyod Jan 30, 2023
6aefe44
Adding more debugging to create mesh
eddyod Jan 30, 2023
5030fb9
Fixed some errors
eddyod Jan 30, 2023
d8545d6
Added the correct machine types for the machine column in the scan ru…
eddyod Feb 7, 2023
d5b388c
Added more useful info to czi_helper script
eddyod Feb 7, 2023
2d24f7c
Added more useful info to czi_helper script, fixed missing parameter
eddyod Feb 7, 2023
de54a9f
Updated cryptography, pyopenssl, torch and torchvision
eddyod Feb 8, 2023
34a75bc
Bump cryptography from 37.0.4 to 39.0.1 in /src/pipeline
dependabot[bot] Feb 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
137 changes: 135 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,136 @@
.vscode/
*.log
parameters.yaml
cvat.yaml
parallel_settings.yaml
# pycharm stuff
.idea/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.pyc

# C extensions
*.so

# Distribution / packaging
.Python
build/
egg-info/
parallel_settings.yaml
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
# images
*.jpg
*.tif

tests/

**/nohup.out*
1 change: 1 addition & 0 deletions archive/cell_density/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
show_cell_density_manager.ipynb
147 changes: 147 additions & 0 deletions archive/cell_density/CellDensityManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import sys
sys.path.append('/scratch/programming/pipeline/pipeline')
from Controllers.SqlController import SqlController
import plotly.graph_objects as go
import numpy as np
import os
from atlas.Atlas import Atlas
from atlas.Assembler import Assembler,get_v7_volume_and_origin,get_assembled_atlas_v7
from scipy.ndimage import zoom
import matplotlib.pyplot as plt

class CellDensityManager(SqlController):
def __init__(self,animal):
super().__init__(animal)
self.assembler = get_assembled_atlas_v7()
self.downsampled_atlas = zoom(self.assembler.combined_volume, (0.1, 0.1, 0.1))
self.resolution = self.get_resolution(self.animal.prep_id).reshape(-1,1)
self.transformation = self.get_transformation(source = self.animal.prep_id,destination = 'Atlas', transformation_type = 'Similarity')

def get_atlas_volume(self):
controller = SqlController(self.animal.prep_id)
atlas = Atlas(atlas = 'atlasV7')
atlas.get_com_array()
assembler = Assembler(check=False,side = '_R')
assembler.volumes,assembler.origins = get_v7_volume_and_origin()
assembler.sqlController = atlas.sqlController
assembler.structures = list(assembler.volumes.keys())
segment_to_id = controller.get_segment_to_id_where_segment_are_brain_regions()
for i in segment_to_id:
segment_to_id[i]=1
assembler.assemble_all_structure_volume(segment_to_id)
return assembler.combined_volume

def plot_3d_volume(self,volume,X,Y,Z,*args,**kwargs):
return go.Volume(
x=X.flatten(),
y=Y.flatten(),
z=Z.flatten(),
value=volume.flatten(),
*args,**kwargs,
)

def hist3d(self,data):
origin = np.min(data,axis = 1).astype(int)
end = np.max(data,axis = 1).astype(int)+1
data = data - np.min(data,axis = 1).reshape(-1,1)
shape = np.max(data,axis = 1).astype(int)
density = np.zeros(shape)
npoints = data.shape[1]
for i in range(npoints):
point = data[:,i].astype(int)-1
density[point[0],point[1],point[2]] += 1
return density,origin,end

def transform_data_to_atlas_space(self,data):
data = data*self.resolution
tfdata = self.transformation.forward_transform_points(data.T).T/np.array([10,10,20]).reshape(-1,1)
tfdata = tfdata*0.1*np.array([1,1,2]).reshape(-1,1)
return tfdata

def get_atlas_plot(self,):
shape = self.downsampled_atlas.shape
X, Y, Z = eval(f'np.mgrid[ 0:{shape[0]}:{shape[0]}j, \
0:{shape[1]}:{shape[1]}j, \
0:{shape[2]*2}:{shape[2]}j]')
atlas = go.Volume(
x=X.flatten(),
y=Y.flatten(),
z=Z.flatten(),
value=self.downsampled_atlas.flatten(),
isomin=1,
isomax=40,
opacity=0.5,
surface_count=2, )
return atlas

def get_density_plot(self,tfdata):
density,origin,end = self.hist3d(tfdata)
shape = density.shape
X, Y, Z = eval(f'np.mgrid[ {origin[0]}:{end[0]}:{shape[0]}j, \
{origin[1]}:{end[1]}:{shape[1]}j, \
{origin[2]}:{end[2]}:{shape[2]}j]')
cell_density = go.Volume(
x=X.flatten(),
y=Y.flatten(),
z=Z.flatten(),
value=density.flatten(),
isomin=1,
isomax=20,
opacity=0.5,
surface_count=20, )
return cell_density

def plot_atlas_and_cell(self,data):
tfdata = self.transform_data_to_atlas_space(data)
atlas = self.get_atlas_plot()
cells = go.Scatter3d(x=tfdata[0], y=tfdata[1], z=tfdata[2],marker=dict(size=5,opacity=0.2),
mode='markers')
fig = go.Figure(data=[atlas,cells])
fig['layout']['scene']['aspectmode'] = "data"
fig.update_layout(scene_aspectmode="data", scene_camera_eye=dict (x=1, y=1, z=1))
fig.show()

def plot_atlas_and_cell_density(self,data):
tfdata = self.transform_data_to_atlas_space(data)
atlas = self.get_atlas_plot()
cell_density = self.get_density_plot(tfdata)
fig = go.Figure(data=[atlas,cell_density])
fig['layout']['scene']['aspectmode'] = "data"
fig.update_layout(scene_aspectmode="data", scene_camera_eye=dict (x=1, y=1, z=1))
fig.show()

def get_id_to_structure(self,segment_to_id):
id_to_structure = {}
ids = list(segment_to_id.values())
structures = list(segment_to_id.keys())
for i,id in enumerate(np.unique(ids)):
index = np.where(ids==id)[0][0]
structure = structures[index]
if '_' in structure:
structure = structure.split('_')[0]
id_to_structure[id] = structure
return id_to_structure

def get_cell_count_per_structure(self,data):
tfdata = self.transform_data_to_atlas_space(data)
npoints = tfdata.shape[1]
category = np.ones(npoints)*-1
for i in range(npoints):
pointi = tfdata[:,i].astype(int)-1
if np.all(pointi>0) and np.all(pointi<self.downsampled_atlas.shape):
category[i] = self.downsampled_atlas[pointi[0],pointi[1],pointi[2]]
segment_to_id = self.get_segment_to_id_where_segment_are_brain_regions()
id_to_structure = self.get_id_to_structure(segment_to_id)
ids,structures = list(id_to_structure.keys()),list(id_to_structure.values())
cell_count_per_structure={}
for i,id in enumerate(ids):
cell_count_per_structure[structures[i]] = sum(category==id)
return ids, cell_count_per_structure

def plot_cell_distribution(self,data):
ids, cell_count_per_structure = self.get_cell_count_per_structure(data)
structures,counts = list(cell_count_per_structure.keys()),list(cell_count_per_structure.values())
plt.figure(figsize = [15,8])
plt.title('Sure Detection Distribution for DK41')
plt.bar(ids,counts, width = 0.4);
plt.xticks(ids, structures, rotation=45);
File renamed without changes.
Loading