AllenInstitute / ophys_etl_pipelines

Pipelines and modules for processing optical physiology data
Other
9 stars 5 forks source link

Refine ROI merging #277

Open danielsf opened 3 years ago

danielsf commented 3 years ago

The ROI merger code from #248 works reasonably well, but could still use refinement. Specifically, in areas of very faint, diffuse flux, the code tends to produce anomalously large ROIs

Ideas to try:

Tasks

Validation

This is probably an open-ended research problem, rather than a ticket with a concrete deliverable

danielsf commented 3 years ago

As a baseline, I will include below results from the ROI merger routine (run on seed segmentation from the Feature Vector Segmenter) from the ROI merger module as it stands. These plots were generated with the following bash script. The experiments were chosen to approximately span the range of behavior vis-a-vis over segmentation.

795901850 is highly over segmented 785569447 is moderately over segmented (and has some significant vasculature shadows) 795897800 did not exhibit significant over-segmentation and probably could have gotten by without mergin.

experiment_ids=(795897800
                785569447
                795901850)

out_dir=/allen/aibs/informatics/danielsf/frog_eggs/pr
dkdir=/allen/programs/braintv/workgroups/nc-ophys/danielk/deepinterpolation
expdir=${dkdir}/experiments

export MKL_NUM_THREADS=1
export OMP_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1

echo ${exp_dir}
for exp_id in ${experiment_ids[@]}
do
    echo ${exp_id}
    log_fname=${out_dir}/${exp_id}_log.txt
    this_dir=${expdir}/ophys_experiment_${exp_id}
    echo 'running '${exp_id}
    nice python -m ophys_etl.modules.segmentation.modules.roi_merging \
    --n_parallel_workers 32 \
    --roi_input ${this_dir}/rois/deep_denoised_filtered_hnc_Gaussian_feature_vec
tor_rois.json  \
    --video_input ${this_dir}/videos/deep_denoised.h5 \
    --corr_acceptance 2.0 \
    --log_level INFO \
    --roi_output ${out_dir}/${exp_id}_rois_2sigma.json >& ${log_fname}
done

In all plots, the upper left subplot is the max projection image from the denoised movie. The upper right subplot is the correlation metric image. The lower left subplot shows ROI boundaries before merging. The lower right subplot shows ROIs after merging (colors are meaningless and just meant to highlight that two adjacent ROIs are, in fact distinct).

In the post-merger ROI plots, uncolored ROIs represent ROIs that were deemed too large to be reasonable, flagged as invalid, and escaped out of further merging. These are the cases that lead me to believe we can do some reasonable winnowing based on the width of the autocorrelation distribution within ROIs.

danielsf commented 3 years ago

Experiment 795901850 (highly over segmented)795901850_merge_output_2sigma_smaller.png

danielsf commented 3 years ago

Experiment 785569447 (moderately over segmented)785569447_merge_output_2sigma_smaller.png

danielsf commented 3 years ago

Experiment 795897800 (probably reasonably segmented on the initial pass)795897800_merge_output_2sigma_smaller.png