Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.1.1] - 2023-08-31

+ Update - Incorporate suggestions from previous PR to improve pytests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+ Update - Incorporate suggestions from previous PR to improve pytests
+ Update - Improve pytests


## [0.1.0] - Unreleased

+ Add - Workflow pipeline, pytests, CICD

[0.1.1]: https://github.com/datajoint/workflow-zstack/releases/tag/0.1.1
[0.1.0]: https://github.com/datajoint/workflow-zstack/releases/tag/0.1.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ a tutorial environment and notebook to learn the pipeline.
to ensure you have `resource-manager` permissions for your account.
2. Follow the instructions below to set up the
[intern](https://github.com/jhuapl-boss/intern) REST API locally.
+ Create a new folder `.intern` in your root directory.
+ Create a new folder `.intern` in your user directory.
+ Create a configuration file `intern.cfg` within the `.intern` folder. The
path to this file should be `~/.intern/intern.cfg`.
+ The `intern.cfg` file should contain the following exactly as shown below:
Expand Down
24 changes: 12 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


sessions_dirs = [
"subject1",
"subject2",
]

# ---------------------- FIXTURES ----------------------
Expand Down Expand Up @@ -57,15 +57,15 @@ def insert_upstream(pipeline):

subject.Subject.insert1(
dict(
subject="subject1",
subject="subject2",
sex="M",
subject_birth_date="2023-01-01",
subject_description="Cellpose segmentation of volumetric data."),
skip_duplicates=True,
)

session_key = dict(
subject="subject1",
subject="subject2",
session_id=0,
)
session.Session.insert1(
Expand All @@ -77,7 +77,7 @@ def insert_upstream(pipeline):
)

session.SessionDirectory.insert1(
dict(session_key, session_dir="subject1/session1"),
dict(session_key, session_dir="subject2"),
skip_duplicates=True,
)
scan.Scan.insert1(
Expand All @@ -102,21 +102,20 @@ def volume_volume(pipeline):


@pytest.fixture(scope="session")
def volume_segmentation_task(pipeline):
def volume_segmentation_param_set(pipeline):
volume = pipeline["volume"]
key = (volume.Volume & "subject='subject1'").fetch1("KEY")
key = (volume.Volume & "subject='subject2'").fetch1("KEY")
volume.SegmentationParamSet.insert_new_params(
segmentation_method="cellpose",
paramset_idx=1,
params=dict(
diameter=8,
diameter=None,
min_size=2,
do_3d=False,
anisotropy=0.5,
model_type="nuclei",
channels=[[0, 0]],
z_axis=0,
skip_duplicates=True,
),
)
yield
Expand All @@ -125,6 +124,7 @@ def volume_segmentation_task(pipeline):
@pytest.fixture(scope="session")
def volume_segmentation_task(pipeline):
volume = pipeline["volume"]
key = (volume.Volume & "subject='subject2'").fetch1("KEY")
volume.SegmentationTask.insert1(dict(
key,
paramset_idx=1,
Expand All @@ -135,15 +135,15 @@ def volume_segmentation_task(pipeline):
@pytest.fixture(scope="session")
def volume_segmentation(pipeline):
volume = pipeline["volume"]
key = (volume.Volume & "subject='subject1'").fetch1("KEY")
key = (volume.Volume & "subject='subject2'").fetch1("KEY")
volume.Segmentation.populate(key)
yield


@pytest.fixture(scope="session")
def volume_voxel_size(pipeline):
volume = pipeline["volume"]
key = (volume.Volume & "subject='subject1'").fetch1("KEY")
key = (volume.Volume & "subject='subject2'").fetch1("KEY")
volume.VoxelSize.insert1(
dict(
key,
Expand All @@ -158,10 +158,10 @@ def volume_voxel_size(pipeline):
def bossdb_volume_upload_task(pipeline):
bossdb = pipeline["bossdb"]
volume = pipeline["volume"]
key = (volume.Segmentation & "subject='subject1'").fetch1("KEY")
key = (volume.Segmentation & "subject='subject2'").fetch1("KEY")
col_name = "dataJointTestUpload"
exp_name = "CaImagingFinal"
chn_name = "test1"
chn_name = "test2"

bossdb.VolumeUploadTask.insert1(
dict(
Expand Down
22 changes: 11 additions & 11 deletions tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def test_export(pipeline):

subject.Subject.insert1(
dict(
subject="subject1",
subject="subject2",
sex="M",
subject_birth_date="2023-01-01",
subject_description="Cellpose segmentation of volumetric data."),
skip_duplicates=True,
)

session_key = dict(
subject="subject1",
subject="subject2",
session_id=0,
)
session.Session.insert1(
Expand All @@ -35,7 +35,7 @@ def test_export(pipeline):
)

session.SessionDirectory.insert1(
dict(session_key, session_dir="subject1/session1"),
dict(session_key, session_dir="subject2"),
skip_duplicates=True,
)
scan.Scan.insert1(
Expand All @@ -46,11 +46,11 @@ def test_export(pipeline):
),
skip_duplicates=True,
)
volume.Volume.populate()
key = (volume.Volume & "subject='subject1'").fetch1("KEY")
volume.Volume.populate(session_key)
key = (volume.Volume & "subject='subject2'").fetch1("KEY")
volume.SegmentationParamSet.insert_new_params(
segmentation_method="cellpose",
paramset_idx=2,
paramset_idx=1,
params=dict(
diameter=None,
min_size=2,
Expand All @@ -59,29 +59,29 @@ def test_export(pipeline):
model_type="nuclei",
channels=[[0, 0]],
z_axis=0,
skip_duplicates=True,
),
)
volume.SegmentationTask.insert1(dict(
key,
paramset_idx=2,
paramset_idx=1,
task_mode="trigger",
),
skip_duplicates=True,
)
segmentation_key = (volume.SegmentationTask & "subject='subject1'").fetch1("KEY")
segmentation_key = (volume.SegmentationTask & "subject='subject2'").fetch1("KEY")
volume.Segmentation.populate(segmentation_key)
volume.VoxelSize.insert1(
dict(
segmentation_key,
**session_key,
scan_id=0,
width=0.001,
height=0.001,
depth=0.001,
)
)
col_name = "dataJointTestUpload"
exp_name = "CaImagingFinal"
chn_name = "test1"
chn_name = "test2"

bossdb.VolumeUploadTask.insert1(
dict(
Expand Down
2 changes: 1 addition & 1 deletion workflow_zstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"VOLUME_ROOT_DATA_DIR", dj.config["custom"].get("volume_root_data_dir", "")
)

db_prefix = dj.config["custom"].get("database.prefix", "")
db_prefix = dj.config["custom"].get("database.prefix", "")
8 changes: 5 additions & 3 deletions workflow_zstack/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ def get_volume_tif_file(scan_key):
Raises:
FileNotFoundError: If the tiff file(s) are not found.
"""
# Folder structure: root / subject / session / .tif (raw)
# Folder structure: root / subject / session / .tif (raw)
sess_dir = find_full_path(
get_volume_root_data_dir(),
pathlib.Path((session.SessionDirectory & scan_key).fetch1("session_dir")),
)

tiff_filepaths = [fp.as_posix() for fp in sess_dir.rglob("*.tif")]

if tiff_filepaths:
assert len(tiff_filepaths) == 1, "More than 1 `.tif` file in file path. Please ensure the session directory contains only 1 image file."
assert (
len(tiff_filepaths) == 1
), "More than 1 `.tif` file in file path. Please ensure the session directory contains only 1 image file."
return tiff_filepaths[0]
else:
raise FileNotFoundError(f"No tiff file found in {sess_dir}")
17 changes: 3 additions & 14 deletions workflow_zstack/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,9 @@

@schema
class Device(dj.Lookup):
"""Table for managing lab equipment.

Attributes:
device ( varchar(32) ): Device short name.
modality ( varchar(64) ): Modality for which this device is used.
description ( varchar(256) ): Optional. Description of device.
"""

definition = """
device : varchar(32)
device_id : smallint
---
modality : varchar(64)
description=null : varchar(256)
device_name : varchar(32) # user-friendly name of the device
device_description : varchar(256)
"""
contents = [
["scanner1", "fluorescence microscope", ""],
]
2 changes: 1 addition & 1 deletion workflow_zstack/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Package metadata."""
__version__ = "0.1.0"
__version__ = "0.1.1"