Skip to content

Commit fbe4a55

Browse files
committed
minor az postprocessing for data analysis
1 parent f516ae4 commit fbe4a55

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ scripts/portal/upscale_tomo.py
1717
analysis_results/
1818
scripts/cooper/revision/evaluation_results/
1919
scripts/cooper/revision/export_tif_to_h5.py
20-
scripts/cooper/revision/copy_path.py
20+
scripts/cooper/revision/copy_path.py
21+
scripts/cooper/revision/view.py
22+
scripts/cooper/revision/count_AZ.py

run_sbatch_revision.sbatch

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/bash
22
#SBATCH -c 4 #4 #8
3-
#SBATCH --mem 256G #120G #32G #64G #256G
3+
#SBATCH --mem 120G #120G #32G #64G #256G
44
#SBATCH -p grete:shared #grete:shared #grete-h100:shared
55
#SBATCH -t 4:00:00 #6:00:00 #48:00:00
66
#SBATCH -G A100:1 #V100:1 #2 #A100:1 #gtx1080:2 #v100:1 #H100:1
@@ -9,4 +9,7 @@
99

1010
source ~/.bashrc
1111
conda activate synapse-net
12-
python scripts/cooper/revision/surface_dice.py -i /mnt/ceph-hdd/cold/nim00007/AZ_prediction_new/stem_for_eval/ -gt /mnt/ceph-hdd/cold/nim00007/new_AZ_train_data/stem_for_eval/ -v 7
12+
python /user/muth9/u12095/synapse-net/scripts/cooper/revision/updated_data_analysis/run_data_analysis.py \
13+
-i /mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/20241102_TOMO_DATA_Imig2014/exported/SNAP25/ \
14+
-o /mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/20241102_TOMO_DATA_Imig2014/afterRevision_analysis/boundaryT0_9_constantins_presynapticFiltering --store \
15+
-s ./analysis_results/man_subset

scripts/cooper/revision/updated_data_analysis/data_analysis.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import numpy as np
2+
from scipy.ndimage import label
3+
from skimage.measure import regionprops
4+
15
from synapse_net.distance_measurements import measure_segmentation_to_object_distances
26
from synapse_net.imod.to_imod import convert_segmentation_to_spheres
37

@@ -14,7 +18,23 @@ def calc_AZ_SV_distance(vesicles, az, resolution):
1418
Returns:
1519
list of dict: Each dict contains 'seg_id' and 'distance', sorted by seg_id.
1620
"""
17-
distances, _, _, seg_ids = measure_segmentation_to_object_distances(vesicles, az, resolution=resolution)
21+
22+
# Apply connected components to az
23+
labeled_az, num_features = label(az)
24+
25+
if num_features == 0:
26+
raise ValueError("No connected components found in active zone segmentation.")
27+
28+
# Measure the size of each component
29+
props = regionprops(labeled_az)
30+
largest_region = max(props, key=lambda r: r.area)
31+
32+
# Create a mask for the largest component only
33+
largest_az_mask = labeled_az == largest_region.label
34+
35+
# Call the distance function with the filtered AZ mask
36+
distances, _, _, seg_ids = measure_segmentation_to_object_distances(vesicles, largest_az_mask, resolution=resolution)
37+
1838

1939
# Exclude seg_id == 0
2040
dist_list = [

0 commit comments

Comments
 (0)