gelles-brandeis / tapqir

Bayesian analysis of co-localization single-molecule microscopy image data.
Apache License 2.0
4 stars 0 forks source link

multi-channel AOI extraction #347

Closed jc-brandeis closed 2 years ago

jc-brandeis commented 2 years ago

errors associate with extracting more than one channel of AOIs:

Extracting AOIs ...
Channel #0 (red_MID2)
100%
1169/1169 [00:11<00:00, 99.95it/s]
Channel #1 (red_Gless)
100%
1169/1169 [00:12<00:00, 91.95it/s]
Processing extracted AOIs ...
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/tapqir/gui.py:353, in glimpseCmd(b, layout, out)
    351 def glimpseCmd(b, layout, out):
    352     with out:
--> 353         glimpse(
    354             **layout.kwargs,
    355             no_input=True,
    356             progress_bar=tqdm_notebook,
    357             labels=False,
    358         )
    360     out.clear_output(wait=True)

File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/tapqir/main.py:311, in glimpse(dataset, P, offset_x, offset_y, offset_P, bin_size, frame_range, frame_start, frame_end, use_offtarget, num_channels, name, glimpse_folder, driftlist, ontarget_aoiinfo, offtarget_aoiinfo, overwrite, no_input, labels, progress_bar)
    304         yaml.dump(
    305             {key: value for key, value in DEFAULTS.items() if key != "cd"},
    306             cfg_file,
    307             sort_keys=False,
    308         )
    310 logger.info("Extracting AOIs ...")
--> 311 read_glimpse(
    312     path=cd,
    313     progress_bar=progress_bar,
    314     **DEFAULTS,
    315 )
    316 logger.info("Extracting AOIs: Done")
    318 return 0

File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/tapqir/imscroll/glimpse_reader.py:392, in read_glimpse(path, progress_bar, **kwargs)
    389 min_data = np.inf
    390 for dtype in data.keys():
    391     # concatenate color channels
--> 392     data[dtype] = np.stack(data[dtype], -3)
    393     target_xy[dtype] = np.stack(target_xy[dtype], -2)
    394     min_data = min(min_data, data[dtype].min())

File <__array_function__ internals>:180, in stack(*args, **kwargs)

File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/numpy/core/shape_base.py:426, in stack(arrays, axis, out)
    424 shapes = {arr.shape for arr in arrays}
    425 if len(shapes) != 1:
--> 426     raise ValueError('all input arrays must have the same shape')
    428 result_ndim = arrays[0].ndim + 1
    429 axis = normalize_axis_index(axis, result_ndim)

ValueError: all input arrays must have the same shape
ordabayevy commented 2 years ago

Can you copy&paste here the content of the config.yaml file which is under the .tapqir folder?

jc-brandeis commented 2 years ago

content of config.yaml

channels:
- name: red_MID2
  glimpse-folder: /home/jchung/test/data_red/jchung00007/
  driftlist: /home/jchung/test/data_red/YNE_30June2022_0007r.dat
  ontarget-aoiinfo: /home/jchung/test/data_red/DNA1_AOIs_red.dat
  offtarget-aoiinfo: /home/jchung/test/data_red/DNA0_AOIs_red.dat
- name: red_Gless
  glimpse-folder: /home/jchung/test/data_red/jchung00007/
  driftlist: /home/jchung/test/data_red/YNE_30June2022_0007r.dat
  ontarget-aoiinfo: /home/jchung/test/data_red/DNA2_AOIs_red.dat
  offtarget-aoiinfo: /home/jchung/test/data_red/DNA0_AOIs_red.dat
P: 14
nbatch-size: 10
fbatch-size: 512
learning-rate: 0.005
num-channels: 2
cuda: true
matlab: false
priors:
  background_mean_std: 1000
  background_std_std: 100
  lamda_rate: 1
  height_std: 10000
  width_min: 0.75
  width_max: 2.25
  proximity_rate: 1
  gain_std: 50
offset-x: 10
offset-y: 10
offset-P: 30
bin-size: 1
dataset: ''
frame-range: false
frame-start: 0
frame-end: 0
use-offtarget: true
labels: false
========================================================
Working directory: /home/jchung/test
Dataset name
​
AOI image size
14
Offset region top-left corner (x-axis)
10
Offset region top-left corner (y-axis)
10
Offset region size
30
Offset histogram bin size (odd number)
1
Specify frame range?
Use off-target AOI locations?
Number of color channels
2
Channel name
red_Gless
Header/glimpse folder
/home/jchung/test/data_red/jchung00007/
Driftlist file
/home/jchung/test/data_red/YNE_30June2022_0007r.dat
Target molecule locations file
/home/jchung/test/data_red/DNA2_AOIs_red.dat
Off-target control locations file
/home/jchung/test/data_red/DNA0_AOIs_red.dat
Extracting AOIs ...
Channel #0 (red_MID2)
100%
1169/1169 [00:12<00:00, 93.99it/s]
Channel #1 (red_Gless)
100%
1169/1169 [00:12<00:00, 89.09it/s]
Processing extracted AOIs ...
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/tapqir/gui.py:353, in glimpseCmd(b, layout, out)
    351 def glimpseCmd(b, layout, out):
    352     with out:
--> 353         glimpse(
    354             **layout.kwargs,
    355             no_input=True,
    356             progress_bar=tqdm_notebook,
    357             labels=False,
    358         )
    360     out.clear_output(wait=True)

File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/tapqir/main.py:311, in glimpse(dataset, P, offset_x, offset_y, offset_P, bin_size, frame_range, frame_start, frame_end, use_offtarget, num_channels, name, glimpse_folder, driftlist, ontarget_aoiinfo, offtarget_aoiinfo, overwrite, no_input, labels, progress_bar)
    304         yaml.dump(
    305             {key: value for key, value in DEFAULTS.items() if key != "cd"},
    306             cfg_file,
    307             sort_keys=False,
    308         )
    310 logger.info("Extracting AOIs ...")
--> 311 read_glimpse(
    312     path=cd,
    313     progress_bar=progress_bar,
    314     **DEFAULTS,
    315 )
    316 logger.info("Extracting AOIs: Done")
    318 return 0

File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/tapqir/imscroll/glimpse_reader.py:392, in read_glimpse(path, progress_bar, **kwargs)
    389 min_data = np.inf
    390 for dtype in data.keys():
    391     # concatenate color channels
--> 392     data[dtype] = np.stack(data[dtype], -3)
    393     target_xy[dtype] = np.stack(target_xy[dtype], -2)
    394     min_data = min(min_data, data[dtype].min())

File <__array_function__ internals>:180, in stack(*args, **kwargs)

File ~/anaconda3/envs/tapqir-env/lib/python3.8/site-packages/numpy/core/shape_base.py:426, in stack(arrays, axis, out)
    424 shapes = {arr.shape for arr in arrays}
    425 if len(shapes) != 1:
--> 426     raise ValueError('all input arrays must have the same shape')
    428 result_ndim = arrays[0].ndim + 1
    429 axis = normalize_axis_index(axis, result_ndim)

ValueError: all input arrays must have the same shape
ordabayevy commented 2 years ago

Is the number of AOIs in two color channels the same or different?

jc-brandeis commented 2 years ago

They are different.

jc-brandeis commented 2 years ago

The errors were caused by using different numbers of AOIs in the 2 channels. The 2-channel processing seems to be working now with the same number of AOIs for both channels.