Skip to content

Commit

Permalink
apply x2
Browse files Browse the repository at this point in the history
  • Loading branch information
tathey1 committed Jan 4, 2024
1 parent ebf9c9c commit d05ab00
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion brainlit/BrainLine/apply_ilastik.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def collect_axon_results(self, brain_id: str, ng_layer_name: str):
]
for layer in ngl_json["layers"]:
if layer["name"] == ng_layer_name:
source_pieces = layer["source"].split("/")
source_pieces = layer["source"]["url"].split("/")
source = ""
for piece in source_pieces[:-1]:
source += piece
Expand Down
46 changes: 36 additions & 10 deletions brainlit/BrainLine/tests/test_apply_ilastik.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
examine_threshold,
ApplyIlastik,
ApplyIlastik_LargeImage,
downsample_mask,
)
import os
import shutil
Expand All @@ -14,6 +15,16 @@
from datetime import date


soma_data_file = (
Path(os.path.abspath(__file__)).parents[3]
/ "docs"
/ "notebooks"
/ "pipelines"
/ "BrainLine"
/ "soma_data.json"
)


@pytest.fixture(scope="session")
def axon_data_dir(tmp_path_factory):
data_dir = tmp_path_factory.mktemp("data")
Expand Down Expand Up @@ -207,10 +218,17 @@ def test_examine_threshold_soma(soma_data_dir):
)


def test_downsample_mask_somafile():
with pytest.raises(ValueError) as e_info:
downsample_mask(brain="placeholder", data_file=soma_data_file)
assert e_info.value.args[0] == f"Entered non-axon data file"


# ApplyIlastik_LargeImage


def test_ApplyIlastik_LargeImage():
def test_ApplyIlastik_LargeImage(soma_data_dir):
# Axon data
data_file = (
Path(os.path.abspath(__file__)).parents[3]
/ "docs"
Expand All @@ -222,16 +240,24 @@ def test_ApplyIlastik_LargeImage():
aili = ApplyIlastik_LargeImage(
ilastik_path="", ilastik_project="", ncpu=1, data_file=data_file
)
aili.collect_axon_results(brain_id="pytest", ng_layer_name="average_10um")
# Sample data is there but file path in data json is specific to thomastathey

data_file = (
Path(os.path.abspath(__file__)).parents[3]
/ "docs"
/ "notebooks"
/ "pipelines"
/ "BrainLine"
/ "soma_data.json"
)
# Soma data
data_dir = soma_data_dir
aili = ApplyIlastik_LargeImage(
ilastik_path="", ilastik_project="", ncpu=1, data_file=data_file
ilastik_path="",
ilastik_project="",
ncpu=1,
data_file=soma_data_file,
results_dir=str(data_dir),
)

somas_path = aili.results_dir / "somas.txt"
print(somas_path)
with open(somas_path, "w") as f:
f.write("[-1, 1, 1]\n")
f.write("[1, 1, 1]\n")
f.write("[2, 1, 1]\n")

aili.collect_soma_results(brain_id="pytest_download")
19 changes: 14 additions & 5 deletions experiments/BrainLine/soma_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -87,9 +87,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Path to brainlit: /Users/thomasathey/Documents/mimlab/mouselight/brainlit_parent/brainlit\n"
]
}
],
"source": [
"brainlit_path = Path(os.path.abspath(\"\"))\n",
"brainlit_path = brainlit_path.parents[1]\n",
Expand Down Expand Up @@ -568,6 +576,7 @@
"\n",
"```\n",
"from cloudreg.scripts.registration import get_affine_matrix\n",
"\n",
"get_affine_matrix([1,1,1], [0,0,0], \"PIR\", \"RPI\", 1.15, \"precomputed://https://open-neurodata.s3.amazonaws.com/ara_2016/sagittal_10um/annotation_10um_2017\")\n",
"```"
]
Expand All @@ -586,7 +595,7 @@
"metadata": {},
"source": [
"```\n",
"python -m cloudreg.scripts.registration -input_s3_path precomputed://s3://smartspim-precomputed-volumes/2023_12_08/MS25/Ch_561 --output_s3_path precomputed://s3://smartspim-precomputed-volumes/2023_12_08/MS25/atlas_to_target --atlas_s3_path https://open-neurodata.s3.amazonaws.com/ara_2016/sagittal_50um/average_50um --parcellation_s3_path https://open-neurodata.s3.amazonaws.com/ara_2016/sagittal_10um/annotation_10um_2017 --atlas_orientation PIR -orientation RPI --rotation -5 0 0 --translation -500 -2000 0 --fixed_scale 1.05 -log_s3_path precomputed://s3://smartspim-precomputed-volumes/2023_12_08/MS25/atlas_to_target --missing_data_correction True --grid_correction False --bias_correction True --regularization 5000.0 --iterations 3000 --registration_resolution 100\n",
"python -m cloudreg.scripts.registration -input_s3_path precomputed://s3://smartspim-precomputed-volumes/2023_12_20/1252B/Ch_561 --output_s3_path precomputed://s3://smartspim-precomputed-volumes/2023_12_20/1252B/atlas_to_target --atlas_s3_path https://open-neurodata.s3.amazonaws.com/ara_2016/sagittal_50um/average_50um --parcellation_s3_path https://open-neurodata.s3.amazonaws.com/ara_2016/sagittal_10um/annotation_10um_2017 --atlas_orientation PIR -orientation RPI --rotation 0 -10 -5 --translation 0 0 0 --fixed_scale 1.1 -log_s3_path precomputed://s3://smartspim-precomputed-volumes/2023_12_20/1252B/atlas_to_target --missing_data_correction True --grid_correction False --bias_correction True --regularization 5000.0 --iterations 3000 --registration_resolution 100\n",
"```"
]
},
Expand Down

0 comments on commit d05ab00

Please sign in to comment.