Open
Description
Hi,
I cropped the sample image and had an odd height, and tried to run it but get the following error:
$ python3 hairyroots.py -i sample/TAKFA3-n3-1_Classes_smaller.tif -o sample/ --id_root 3 --id_roothair 1 --id_background 2 --pixel_size 1.72 -p
usage: hairyroots.py [-h] [-i INPUT_PATH] [-o OUTPUT_PATH] [-p] [--pixel_size PIXEL_SIZE] [--id_root ID_ROOT] [--id_background ID_BACKGROUND] [--id_roothair ID_ROOTHAIR] [--max_dist MAX_DIST] [--thresh_d2r THRESH_DIST_TO_ROOT]
[--prune IS_PRUNE] [--bin_op IS_CLOSE_GAPS] [--measure {strain_energy,total_curvature}] [--cost_type {mean,exp,rms,pow3,pow4,geom}] [--n_levels N_LEVELS] [--n_repeats N_REPEATS] [--use_ref_tips] [--no_ref_tips]
[--w_curve W_CURVE] [--w_len W_LEN] [--w_mind W_MIND]
Extracts and measures root hairs from classified image.
optional arguments:
-h, --help show this help message and exit
-i INPUT_PATH, --in INPUT_PATH
tiff input file
-o OUTPUT_PATH, --out OUTPUT_PATH
csv output filename
-p, --print Select to output other data
--pixel_size PIXEL_SIZE
pixel size in microns per pixel
--id_root ID_ROOT id of root
--id_background ID_BACKGROUND
id of background
--id_roothair ID_ROOTHAIR
id of root hairs
--max_dist MAX_DIST Maximum distance of root hair clusters to root in pixels.
--thresh_d2r THRESH_DIST_TO_ROOT
Minimum distance of root hair to root
--prune IS_PRUNE Preprocessing step: Prune medial axis
--bin_op IS_CLOSE_GAPS
Preprocessing step: Binary opening/closing
--measure {strain_energy,total_curvature}
Type of curvature measure
--cost_type {mean,exp,rms,pow3,pow4,geom}
Way to summarize optimization objectives.
--n_levels N_LEVELS Minimum number of iteration levels for optimization.
--n_repeats N_REPEATS
Number of times simulated annealing is repeated.
--use_ref_tips Treat tips separately from non-tips for referance values.
--no_ref_tips Do not treat tips separately from non-tips for referance values.
--w_curve W_CURVE Weight for curvature optimzation.
--w_len W_LEN Weight for length optimzation.
--w_mind W_MIND Weight for minimum distance to root optimzation.
usage: hairyroots.py [-h] [-i INPUT_PATH] [-o OUTPUT_PATH] [-p] [--pixel_size PIXEL_SIZE] [--id_root ID_ROOT] [--id_background ID_BACKGROUND] [--id_roothair ID_ROOTHAIR] [--max_dist MAX_DIST] [--thresh_d2r THRESH_DIST_TO_ROOT]
[--prune IS_PRUNE] [--bin_op IS_CLOSE_GAPS] [--measure {strain_energy,total_curvature}] [--cost_type {mean,exp,rms,pow3,pow4,geom}] [--n_levels N_LEVELS] [--n_repeats N_REPEATS] [--use_ref_tips] [--no_ref_tips]
[--w_curve W_CURVE] [--w_len W_LEN] [--w_mind W_MIND]
Namespace(input_path='sample/TAKFA3-n3-1_Classes_smaller.tif', output_path='sample/', print_all=True, pixel_size=1.72, id_root=3, id_background=2, id_roothair=1, max_dist=10, thresh_dist_to_root=10, is_prune=True, is_close_gaps=True, measure='total_curvature', cost_type='rms', n_levels=1000, n_repeats=1, use_ref_tips=True, w_curve=1.0, w_len=1.0, w_mind=1.0, func=<function run_pipeline at 0x14614fab9160>)
memory use: 0.1386
Elapsed time: 00:00:00
memory use: 0.1578
Elapsed time: 00:00:00
Traceback (most recent call last):
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/hairyroots.py", line 579, in <module>
main()
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/hairyroots.py", line 574, in main
args.func(args)
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/hairyroots.py", line 84, in run_pipeline
ma, ma_dist, dist_to_root, data = prep.run(data)
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/preprocessing.py", line 37, in run
classes = self.removeFarRootHairs(classes, max_distance=self.max_distance, id_root=self.id_root, id_background=self.id_background, id_roothair=self.id_roothair)
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/preprocessing.py", line 122, in removeFarRootHairs
edge = self.find_edge(img, id_root) # pixel coordinates of edge of main root
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/preprocessing.py", line 292, in find_edge
n_neighbours_edge = segmentation.Segmentation.numOfNeighbours(edge_loc, arr)
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/segmentation.py", line 86, in numOfNeighbours
nneighbours = rank.sum(arrBinary, a) # sum of neighbouring pixels
File "/dodrio/scratch/projects/starting_2023_001/bpavie/dirtmu_env/lib/python3.9/site-packages/skimage/_shared/utils.py", line 282, in fixed_func
return func(*args, **kwargs)
File "/dodrio/scratch/projects/starting_2023_001/bpavie/dirtmu_env/lib/python3.9/site-packages/skimage/filters/rank/generic.py", line 1068, in sum
return _apply_scalar_per_pixel_3D(generic_cy._sum_3D, image,
File "/dodrio/scratch/projects/starting_2023_001/bpavie/dirtmu_env/lib/python3.9/site-packages/skimage/filters/rank/generic.py", line 276, in _apply_scalar_per_pixel_3D
image, footprint, out, mask, n_bins = _handle_input_3D(
File "/dodrio/scratch/projects/starting_2023_001/bpavie/dirtmu_env/lib/python3.9/site-packages/skimage/filters/rank/generic.py", line 198, in _handle_input_3D
raise ValueError('Image dimensions and neighborhood dimensions'
ValueError: Image dimensions and neighborhood dimensions do not match
When I re-crop the image to none odd width/height, it works, but I get a different error at the end of the analysis:
$ python3 hairyroots.py -i sample/TAKFA3-n3-1_Classes_smaller.tif -o sample/ --id_root 3 --id_roothair 1 --id_background 2 --pixel_size 1.72 -p
usage: hairyroots.py [-h] [-i INPUT_PATH] [-o OUTPUT_PATH] [-p] [--pixel_size PIXEL_SIZE] [--id_root ID_ROOT] [--id_background ID_BACKGROUND] [--id_roothair ID_ROOTHAIR] [--max_dist MAX_DIST] [--thresh_d2r THRESH_DIST_TO_ROOT]
[--prune IS_PRUNE] [--bin_op IS_CLOSE_GAPS] [--measure {strain_energy,total_curvature}] [--cost_type {mean,exp,rms,pow3,pow4,geom}] [--n_levels N_LEVELS] [--n_repeats N_REPEATS] [--use_ref_tips] [--no_ref_tips]
[--w_curve W_CURVE] [--w_len W_LEN] [--w_mind W_MIND]
Extracts and measures root hairs from classified image.
optional arguments:
-h, --help show this help message and exit
-i INPUT_PATH, --in INPUT_PATH
tiff input file
-o OUTPUT_PATH, --out OUTPUT_PATH
csv output filename
-p, --print Select to output other data
--pixel_size PIXEL_SIZE
pixel size in microns per pixel
--id_root ID_ROOT id of root
--id_background ID_BACKGROUND
id of background
--id_roothair ID_ROOTHAIR
id of root hairs
--max_dist MAX_DIST Maximum distance of root hair clusters to root in pixels.
--thresh_d2r THRESH_DIST_TO_ROOT
Minimum distance of root hair to root
--prune IS_PRUNE Preprocessing step: Prune medial axis
--bin_op IS_CLOSE_GAPS
Preprocessing step: Binary opening/closing
--measure {strain_energy,total_curvature}
Type of curvature measure
--cost_type {mean,exp,rms,pow3,pow4,geom}
Way to summarize optimization objectives.
--n_levels N_LEVELS Minimum number of iteration levels for optimization.
--n_repeats N_REPEATS
Number of times simulated annealing is repeated.
--use_ref_tips Treat tips separately from non-tips for referance values.
--no_ref_tips Do not treat tips separately from non-tips for referance values.
--w_curve W_CURVE Weight for curvature optimzation.
--w_len W_LEN Weight for length optimzation.
--w_mind W_MIND Weight for minimum distance to root optimzation.
usage: hairyroots.py [-h] [-i INPUT_PATH] [-o OUTPUT_PATH] [-p] [--pixel_size PIXEL_SIZE] [--id_root ID_ROOT] [--id_background ID_BACKGROUND] [--id_roothair ID_ROOTHAIR] [--max_dist MAX_DIST] [--thresh_d2r THRESH_DIST_TO_ROOT]
[--prune IS_PRUNE] [--bin_op IS_CLOSE_GAPS] [--measure {strain_energy,total_curvature}] [--cost_type {mean,exp,rms,pow3,pow4,geom}] [--n_levels N_LEVELS] [--n_repeats N_REPEATS] [--use_ref_tips] [--no_ref_tips]
[--w_curve W_CURVE] [--w_len W_LEN] [--w_mind W_MIND]
Namespace(input_path='sample/TAKFA3-n3-1_Classes_smaller.tif', output_path='sample/', print_all=True, pixel_size=1.72, id_root=3, id_background=2, id_roothair=1, max_dist=10, thresh_dist_to_root=10, is_prune=True, is_close_gaps=True, measure='total_curvature', cost_type='rms', n_levels=1000, n_repeats=1, use_ref_tips=True, w_curve=1.0, w_len=1.0, w_mind=1.0, func=<function run_pipeline at 0x14ca644db160>)
memory use: 0.1429
Elapsed time: 00:00:00
memory use: 0.1534
Elapsed time: 00:00:00
cleaning up tips...
cleaning up tips...
cleaning up tips...
memory use: 0.2658
Elapsed time: 00:00:31
memory use: 0.3268
Elapsed time: 00:00:14
**************************************************
Getting candidates
# of connected components:80
**************************************************
Component 0: 3190 nodes
- 313449 candidates; memory use: 0.5601
Component 1: 3 nodes
- 1 candidates; memory use: 0.5604
Component 2: 3 nodes
- 1 candidates; memory use: 0.5604
Component 3: 3 nodes
- 1 candidates; memory use: 0.5604
Component 4: 3 nodes
- 1 candidates; memory use: 0.5604
Component 5: 3 nodes
- 1 candidates; memory use: 0.5604
Component 6: 3 nodes
- 1 candidates; memory use: 0.5604
Component 7: 3 nodes
- 1 candidates; memory use: 0.5604
Component 8: 3 nodes
- 1 candidates; memory use: 0.5604
Component 9: 3 nodes
- 1 candidates; memory use: 0.5604
Component 10: 3 nodes
- 1 candidates; memory use: 0.5604
Component 11: 3 nodes
- 1 candidates; memory use: 0.5604
Component 12: 3 nodes
- 1 candidates; memory use: 0.5604
Component 13: 3 nodes
- 1 candidates; memory use: 0.5604
Component 14: 3 nodes
- 1 candidates; memory use: 0.5604
Component 15: 1133 nodes
- 96109 candidates; memory use: 0.6331
Component 16: 3 nodes
- 1 candidates; memory use: 0.6331
Component 17: 3 nodes
- 1 candidates; memory use: 0.6331
Component 18: 3 nodes
- 1 candidates; memory use: 0.6331
Component 19: 3 nodes
- 1 candidates; memory use: 0.6331
Component 20: 3 nodes
- 1 candidates; memory use: 0.6331
Component 21: 642 nodes
- 53291 candidates; memory use: 0.6739
Component 22: 3 nodes
- 1 candidates; memory use: 0.6741
Component 23: 5 nodes
- 1 candidates; memory use: 0.6741
Component 24: 3 nodes
- 1 candidates; memory use: 0.6741
Component 25: 3 nodes
- 1 candidates; memory use: 0.6741
Component 26: 617 nodes
- 45310 candidates; memory use: 0.7082
Component 27: 3 nodes
- 1 candidates; memory use: 0.7082
Component 28: 3 nodes
- 1 candidates; memory use: 0.7082
Component 29: 3 nodes
- 1 candidates; memory use: 0.7082
Component 30: 3 nodes
- 1 candidates; memory use: 0.7082
Component 31: 3 nodes
- 1 candidates; memory use: 0.7082
Component 32: 3 nodes
- 1 candidates; memory use: 0.7082
Component 33: 3 nodes
- 1 candidates; memory use: 0.7082
Component 34: 3 nodes
- 1 candidates; memory use: 0.7082
Component 35: 3 nodes
- 1 candidates; memory use: 0.7082
Component 36: 3 nodes
- 1 candidates; memory use: 0.7082
Component 37: 3 nodes
- 1 candidates; memory use: 0.7082
Component 38: 3 nodes
- 1 candidates; memory use: 0.7082
Component 39: 3 nodes
- 1 candidates; memory use: 0.7082
Component 40: 3 nodes
- 1 candidates; memory use: 0.7082
Component 41: 3 nodes
- 1 candidates; memory use: 0.7082
Component 42: 3 nodes
- 1 candidates; memory use: 0.7082
Component 43: 3 nodes
- 1 candidates; memory use: 0.7082
Component 44: 3 nodes
- 1 candidates; memory use: 0.7082
Component 45: 3 nodes
- 1 candidates; memory use: 0.7082
Component 46: 3 nodes
- 1 candidates; memory use: 0.7082
Component 47: 3 nodes
- 1 candidates; memory use: 0.7082
Component 48: 3 nodes
- 1 candidates; memory use: 0.7082
Component 49: 3 nodes
- 1 candidates; memory use: 0.7082
Component 50: 3 nodes
- 1 candidates; memory use: 0.7082
Component 51: 3 nodes
- 1 candidates; memory use: 0.7082
Component 52: 3 nodes
- 1 candidates; memory use: 0.7082
Component 53: 3 nodes
- 1 candidates; memory use: 0.7082
Component 54: 3 nodes
- 1 candidates; memory use: 0.7082
Component 55: 3 nodes
- 1 candidates; memory use: 0.7082
Component 56: 3 nodes
- 1 candidates; memory use: 0.7082
Component 57: 3 nodes
- 1 candidates; memory use: 0.7082
Component 58: 3 nodes
- 1 candidates; memory use: 0.7082
Component 59: 3 nodes
- 1 candidates; memory use: 0.7082
Component 60: 3 nodes
- 1 candidates; memory use: 0.7082
Component 61: 3 nodes
- 1 candidates; memory use: 0.7082
Component 62: 3 nodes
- 1 candidates; memory use: 0.7082
Component 63: 3 nodes
- 1 candidates; memory use: 0.7082
Component 64: 3 nodes
- 1 candidates; memory use: 0.7082
Component 65: 3 nodes
- 1 candidates; memory use: 0.7082
Component 66: 3 nodes
- 1 candidates; memory use: 0.7082
Component 67: 3 nodes
- 1 candidates; memory use: 0.7082
Component 68: 3 nodes
- 1 candidates; memory use: 0.7082
Component 69: 3 nodes
- 1 candidates; memory use: 0.7082
Component 70: 3 nodes
- 1 candidates; memory use: 0.7082
Component 71: 3 nodes
- 1 candidates; memory use: 0.7082
Component 72: 1 nodes
- 0 candidates; memory use: 0.7082
Component 73: 3 nodes
- 1 candidates; memory use: 0.7082
Component 74: 3 nodes
- 1 candidates; memory use: 0.7082
Component 75: 3 nodes
- 1 candidates; memory use: 0.7082
Component 76: 11 nodes
- 15 candidates; memory use: 0.7082
Component 77: 3 nodes
- 1 candidates; memory use: 0.7082
Component 78: 3 nodes
- 1 candidates; memory use: 0.7082
Component 79: 3 nodes
- 1 candidates; memory use: 0.7082
memory use: 0.7082
Gathering data for dummies...
memory use: 0.7151
Gathering data for candidates...
- 508248 candidate(s)
- Candidate 0
- Candidate 10000
- Candidate 20000
- Candidate 30000
- Candidate 40000
- Candidate 50000
- Candidate 60000
- Candidate 70000
- Candidate 80000
- Candidate 90000
- Candidate 100000
- Candidate 110000
- Candidate 120000
- Candidate 130000
- Candidate 140000
- Candidate 150000
- Candidate 160000
- Candidate 170000
- Candidate 180000
- Candidate 190000
- Candidate 200000
- Candidate 210000
- Candidate 220000
- Candidate 230000
- Candidate 240000
- Candidate 250000
- Candidate 260000
- Candidate 270000
- Candidate 280000
- Candidate 290000
- Candidate 300000
- Candidate 310000
- Candidate 320000
- Candidate 330000
- Candidate 340000
- Candidate 350000
- Candidate 360000
- Candidate 370000
- Candidate 380000
- Candidate 390000
- Candidate 400000
- Candidate 410000
- Candidate 420000
- Candidate 430000
- Candidate 440000
- Candidate 450000
- Candidate 460000
- Candidate 470000
- Candidate 480000
- Candidate 490000
- Candidate 500000
Traceback (most recent call last):
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/hairyroots.py", line 579, in <module>
main()
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/hairyroots.py", line 574, in main
args.func(args)
File "/dodrio/scratch/projects/starting_2023_001/bpavie/DIRTmu/hairyroots.py", line 207, in run_pipeline
good_candidates = np.array(all_candidates)[candidate_filter] #[all_candidates[i] for i in candidate_filter]
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (508248,) + inhomogeneous part.
NB:
I created the python conda env using this yaml file on linux, which seems to install create a correct conda env to run DIRT/mu
name: DIRTmu_env_py3
channels:
- conda-forge
- defaults
- conda-forge/label/cf202003
dependencies:
- python=3.9.10
- graph-tool
- pip
- scipy=1.8.0
- scikit-image=0.19.2
- scikit-learn=1.0.2
- matplotlib=3.5.1
- matplotlib-base=3.5.1
- psutil=5.9.0
- pandas=1.4.1
Metadata
Metadata
Assignees
Labels
No labels