Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luiztauffer committed Aug 27, 2024
2 parents 25ab15e + c2cf159 commit d46ab92
Show file tree
Hide file tree
Showing 31 changed files with 769 additions and 536 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ __pycache__/
*.pyc
*.egg-info


# Python coverage files
.coverage
.coverage.*
Expand Down
21 changes: 21 additions & 0 deletions README-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Voluseg container

Build the image:
```bash
DOCKER_BUILDKIT=1 docker build -t voluseg .
```

Run with local data volume mount:
```bash
docker run -v $(pwd)/data:/voluseg/data voluseg
```

Run with local data volume mount and hot reload for the voluseg package:
```bash
docker run \
-v $(pwd)/sample_data:/voluseg/data \
-v $(pwd)/output:/voluseg/output \
-v $(pwd)/voluseg:/voluseg/voluseg \
-v $(pwd)/app:/voluseg/app \
voluseg
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Contact: Mika Rubinov, `mika.rubinov at vanderbilt.edu`

# example code

```
```python
# set up
import os
import pprint
Expand Down
19 changes: 8 additions & 11 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# set up
import os
import pprint
import voluseg

# check for updates
# voluseg.update()

# set and save parameters
parameters0 = voluseg.parameter_dictionary()
parameters0['dir_ants'] = '/ants-2.5.3/bin/'
parameters0['dir_input'] = '/voluseg/data/'
parameters0['dir_output'] = '/voluseg/output/'
parameters0['registration'] = 'high'
parameters0['diam_cell'] = 5.0
parameters0['f_volume'] = 2.0
parameters0["dir_ants"] = "/ants-2.5.3/bin/"
parameters0["dir_input"] = "/voluseg/data/"
parameters0["dir_output"] = "/voluseg/output/"
parameters0["registration"] = "high"
parameters0["diam_cell"] = 5.0
parameters0["f_volume"] = 2.0
voluseg.step0_process_parameters(parameters0)

# load and print parameters
filename_parameters = os.path.join(parameters0['dir_output'], 'parameters.pickle')
filename_parameters = os.path.join(parameters0["dir_output"], "parameters.pickle")
parameters = voluseg.load_parameters(filename_parameters)
pprint.pprint(parameters)

Expand All @@ -34,4 +31,4 @@
voluseg.step4_detect_cells(parameters)

print("clean cells.")
voluseg.step5_clean_cells(parameters)
voluseg.step5_clean_cells(parameters)
2 changes: 1 addition & 1 deletion requirements-docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ matplotlib==3.9.2
numpy==2.1.0
pandas==2.2.2
pyspark==3.4.0
pynwb==2.8.1
pynwb==2.8.1
32 changes: 14 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
'''volumetric segmentation pipeline'''
"""volumetric segmentation pipeline"""

import setuptools

with open('README.md', 'r') as fh:
with open("README.md", "r") as fh:
README = fh.read()

# with open('requirements.txt', 'r') as fh:
# install_requires = fh.read().split('\n')

setuptools.setup(
name='voluseg',
version='2023.12',
author='Mika Rubinov',
author_email='mika.rubinov@vanderbilt.edu',
description='pipeline for volumetric segmentation of calcium imaging data',
name="voluseg",
version="2023.12",
author="Mika Rubinov",
author_email="mika.rubinov@vanderbilt.edu",
description="pipeline for volumetric segmentation of calcium imaging data",
long_description=README,
long_description_content_type='text/markdown',
url='https://github.com/mikarubi/voluseg',
packages=[
'voluseg',
'voluseg._steps',
'voluseg._tools'
],
long_description_content_type="text/markdown",
url="https://github.com/mikarubi/voluseg",
packages=["voluseg", "voluseg._steps", "voluseg._tools"],
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.5',
python_requires=">=3.5",
# install_requires=install_requires
)
34 changes: 22 additions & 12 deletions tests/test_voluseg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
def setup_parameters(tmp_path):
# Define parameters and paths
parameters0 = voluseg.parameter_dictionary()
parameters0['dir_ants'] = "/home/luiz/Downloads/ants-2.5.2/bin" # Change this to your actual ANTs bin path
parameters0["dir_ants"] = (
"/home/luiz/Downloads/ants-2.5.2/bin" # Change this to your actual ANTs bin path
)
# parameters0['dir_input'] = str((Path(".").resolve().parent / "sample_data"))
parameters0['dir_input'] = "/mnt/shared_storage/taufferconsulting/client_catalystneuro/project_voluseg/sample_data"
parameters0["dir_input"] = (
"/mnt/shared_storage/taufferconsulting/client_catalystneuro/project_voluseg/sample_data"
)
# parameters0['dir_output'] = str(tmp_path) # Use pytest's tmp_path fixture for output
parameters0['dir_output'] = "/mnt/shared_storage/taufferconsulting/client_catalystneuro/project_voluseg/output"
parameters0['registration'] = 'high'
parameters0['diam_cell'] = 5.0
parameters0['f_volume'] = 2.0
parameters0["dir_output"] = (
"/mnt/shared_storage/taufferconsulting/client_catalystneuro/project_voluseg/output"
)
parameters0["registration"] = "high"
parameters0["diam_cell"] = 5.0
parameters0["f_volume"] = 2.0

# Save parameters
voluseg.step0_process_parameters(parameters0)
Expand All @@ -26,7 +32,9 @@ def setup_parameters(tmp_path):


def test_voluseg_pipeline_h5_dir(setup_parameters):
filename_parameters = os.path.join(setup_parameters['dir_output'], 'parameters.pickle')
filename_parameters = os.path.join(
setup_parameters["dir_output"], "parameters.pickle"
)
parameters = voluseg.load_parameters(filename_parameters)
pprint.pprint(parameters)

Expand Down Expand Up @@ -57,15 +65,17 @@ def test_voluseg_pipeline_h5_dir(setup_parameters):
def test_voluseg_pipeline_nwbfile(setup_parameters):
from voluseg._tools.nwb import h5_dir_to_nwb_file

filename_parameters = os.path.join(setup_parameters['dir_output'], 'parameters.pickle')
filename_parameters = os.path.join(
setup_parameters["dir_output"], "parameters.pickle"
)
parameters = voluseg.load_parameters(filename_parameters)

# Convert a directory of HDF5 files to a single NWB file
nwb_file_path = str(os.path.join(parameters['dir_output'], "output.nwb"))
nwb_file_path = str(os.path.join(parameters["dir_output"], "output.nwb"))
h5_dir_to_nwb_file(
h5_dir=parameters['dir_input'],
h5_dir=parameters["dir_input"],
acquisition_name="TwoPhotonSeries",
output_file_path=nwb_file_path
output_file_path=nwb_file_path,
)
parameters["nwb_input_local_path"] = nwb_file_path
parameters["nwb_input_acquisition_name"] = "TwoPhotonSeries"
Expand All @@ -87,4 +97,4 @@ def test_voluseg_pipeline_nwbfile(setup_parameters):
# voluseg.step4_detect_cells(parameters)

# print("Clean cells.")
# voluseg.step5_clean_cells(parameters)
# voluseg.step5_clean_cells(parameters)
2 changes: 1 addition & 1 deletion voluseg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''initialization'''
"""initialization"""

from voluseg._steps.step0 import process_parameters as step0_process_parameters
from voluseg._steps.step1 import process_volumes as step1_process_volumes
Expand Down
8 changes: 6 additions & 2 deletions voluseg/_steps/step0.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ def process_parameters(parameters0: dict) -> None:
if not acquisition_name:
raise Exception("nwb_input_acquisition_name is required to read nwb file")
volume_fullnames_input = [parameters.get("nwb_input_local_path")]
volume_names = [parameters.get("nwb_input_local_path").split("/")[-1].split(".nwb")[0]]
with open_nwbfile_local(file_path=parameters["nwb_input_local_path"]) as nwbfile:
volume_names = [
parameters.get("nwb_input_local_path").split("/")[-1].split(".nwb")[0]
]
with open_nwbfile_local(
file_path=parameters["nwb_input_local_path"]
) as nwbfile:
lt = nwbfile.acquisition[acquisition_name].data.shape[0]
if parameters["timepoints"]:
lt = min(lt, parameters["timepoints"])
Expand Down
7 changes: 5 additions & 2 deletions voluseg/_steps/step1.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def make_output_volume(name_volume, volume):
volume_index=tuple_fullname_volume_input[1],
)
make_output_volume(
name_volume=p.volume_names[0] + f"_{tuple_fullname_volume_input[1]}",
name_volume=p.volume_names[0]
+ f"_{tuple_fullname_volume_input[1]}",
volume=volume,
)
else:
Expand All @@ -136,7 +137,9 @@ def make_output_volume(name_volume, volume):
if len(p.input_dirs) == 1:
dir_prefix = None
else:
dir_prefix = os.path.basename(os.path.split(fullname_volume_input)[0])
dir_prefix = os.path.basename(
os.path.split(fullname_volume_input)[0]
)

# process output volumes
if p.planes_packed:
Expand Down
Loading

0 comments on commit d46ab92

Please sign in to comment.