Skip to content

Commit

Permalink
upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tathey1 committed Nov 8, 2023
1 parent 08e131f commit 19efbaf
Show file tree
Hide file tree
Showing 5 changed files with 1,072 additions and 1,091 deletions.
1,990 changes: 947 additions & 1,043 deletions experiments/BrainLine/axon_analysis.ipynb

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions experiments/BrainLine/data/axon_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@
"url": "https://viz.neurodata.io/?json_url=https://json.neurodata.io/v1?NGStateID=30O_uxkW67rv2Q",
"layer": "val"
},
"subtype": "gad2 vgat"
"subtype": "gad2 vgat",
"transformed_mask": "precomputed://s3://smartspim-precomputed-volumes/2023_05_24/MS9/axon_mask_transformed"
},
"MS33": {
"base": "precomputed://s3://smartspim-precomputed-volumes/2023_09_18/MS33/",
Expand All @@ -245,7 +246,8 @@
"url": "/Users/thomasathey/Documents/mimlab/mouselight/ailey/detection_axon/brainMS33/train.json",
"layer": "train"
},
"subtype": "tph2 gad2"
"subtype": "tph2 gad2",
"transformed_mask": "precomputed://s3://smartspim-precomputed-volumes/2023_09_18/MS33/axon_mask_transformed"
},
"pytest": {
"subtype": "test_type"
Expand Down
3 changes: 2 additions & 1 deletion experiments/BrainLine/data/soma_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@
"somas_layer": "soma_val",
"nonsomas_layer": "nonsoma_val"
},
"subtype": "gad2 vgat"
"subtype": "gad2 vgat",
"somas_atlas_url": "https://ara.viz.neurodata.io/?json_url=https://json.neurodata.io/v1?NGStateID=ebbZ0XEKgFjHKg"
}
},
"brain2centers": {
Expand Down
66 changes: 66 additions & 0 deletions experiments/BrainLine/scripts/upload_mask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from cloudvolume import CloudVolume
from brainlit.BrainLine.apply_ilastik import ApplyIlastik_LargeImage
from brainlit.BrainLine.util import _get_corners
import json
import numpy as np
from pathlib import Path
import os
from tqdm import tqdm

local_vol = CloudVolume("precomputed://file:///mnt/data/Neuroglancer_Data/2023_04_10/MS12/axon_mask")

brain_id = "MS12"
antibody_layer = "Ch_647"
background_layer = "Ch_561"
endogenous_layer = "Ch_488"

brainline_exp_dir = Path(os.getcwd()) / Path(__file__).parents[1]
data_dir = (
brainline_exp_dir / "data" / "brain_temp"
) # data_dir = "/data/tathey1/matt_wright/brain_temp/" # directory to store temporary subvolumes for segmentation
data_file = brainline_exp_dir / "data" / "axon_data.json"
layer_names = [antibody_layer, background_layer, endogenous_layer]
chunk_size = [1024, 1024, 1024] # [256, 256, 300]
ncpu = 2


ilastik_path = "/Applications/ilastik-1.4.0b21-OSX.app/Contents/ilastik-release/run_ilastik.sh" # "/data/tathey1/matt_wright/ilastik/ilastik-1.4.0rc5-Linux/run_ilastik.sh" # path to ilastik executable
ilastik_project = brainline_exp_dir / "data" / "models" / "axon" / "axon_segmentation.ilp" # "/data/tathey1/matt_wright/ilastik/model1/axon_segmentation.ilp" # path to ilastik
ilastik_path = "/home/user/Documents/ilastik-1.4.0-Linux/run_ilastik.sh"

alli = ApplyIlastik_LargeImage(
ilastik_path=ilastik_path,
ilastik_project=ilastik_project,
ncpu=ncpu,
data_file=data_file,
)



with open(data_file) as f:
data = json.load(f)
object_type = data["object_type"]
brain2paths = data["brain2paths"]

volume_base_dir_write = brain2paths[brain_id]["base_s3"]
volume_base_dir_read = brain2paths[brain_id]["base_local"]
mask_dir = volume_base_dir_write + "axon_mask"

sample_path = volume_base_dir_read + layer_names[1]
vol = CloudVolume(sample_path, parallel=True, mip=0, fill_missing=True)


try:
CloudVolume(mask_dir)
except:
assert np.all([c_ilastik % c_vol == 0 for c_ilastik, c_vol in zip(chunk_size, [128, 128, 2])])
alli._make_mask_info(mask_dir, vol, [128, 128, 2])

s3_vol = CloudVolume(mask_dir)

corners = _get_corners(local_vol.shape, local_vol.chunks)

for corner in tqdm(corners):
s3_vol[corner[0][0]:corner[1][0],corner[0][1]:corner[1][1],corner[0][2]:corner[1][2]] = local_vol[corner[0][0]:corner[1][0],corner[0][1]:corner[1][1],corner[0][2]:corner[1][2]]


Loading

0 comments on commit 19efbaf

Please sign in to comment.