"{} empty ROIs found".format(original_n_rois - n_rois))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile
execfile(filename, namespace)
File "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/jackw/Desktop/SIMA example code.py", line 109, in <module>
dataset.extract(signal_channel='GCaMP', label='GCaMP_signals')
File "C:\Anaconda\lib\site-packages\sima\imaging.py", line 726, in extract
demix_channel=demix_channel, save_summary=save_summary
File "C:\Anaconda\lib\site-packages\sima\extract.py", line 517, in save_extracted_signals
signal_channel=signal_channel, **kwargs)
File "C:\Anaconda\lib\site-packages\sima\extract.py", line 348, in extract_rois
raise ValueError('No valid ROIs found.')
ValueError: No valid ROIs found.
import sima.motion
import sima.segment
tiff_filenames = [['test_dir/Cycle{n1:02d}_Ch{n2}.tif'.format(n1=cycle, n2=channel) for channel in range(1, 3)] for cycle in range(1, 16)]
print "TIFF filenames:\n", tiff_filenames
sequences = [sima.Sequence.join(*[sima.Sequence.create('TIFF', chan) for chan in cycle]) for cycle in tiff_filenames]
dataset_path = 'test_dir/dataset.sima'
correction_approach = sima.motion.HiddenMarkov2D(num_states_retained=30, max_displacement=[20, 30])
dataset = correction_approach.correct(sequences, dataset_path, channel_names=['tdTomato', 'GCaMP'], trim_criterion=0.95)
output_filenames = [[[channel.replace('.tif', '_corrected.tif') for channel in cycle]] for cycle in tiff_filenames]
print "Output filenames:\n", output_filenames
dataset.export_frames(output_filenames, fill_gaps=True)
segmentation_approach = sima.segment.STICA(mu=0.5)
dataset.segment(segmentation_approach, 'auto_ROIs')
dataset.extract(signal_channel='GCaMP', label='GCaMP_signals')
dataset.export_signals('example_signals.csv', channel='GCaMP', signals_label='GCaMP_signals')
--
You received this message because you are subscribed to the Google Groups "sima-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sima-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sima-users/9faab5eb-2e25-4b06-81f7-e4661f9f71c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
1.2.1
Started at 2015-06-09 17:52:58.596000
TIFF filenames:
[['test_dir/Cycle01_Ch1.tif', 'test_dir/Cycle01_Ch2.tif'], ['test_dir/Cycle02_Ch1.tif', 'test_dir/Cycle02_Ch2.tif'], ['test_dir/Cycle03_Ch1.tif', 'test_dir/Cycle03_Ch2.tif'], ['test_dir/Cycle04_Ch1.tif', 'test_dir/Cycle04_Ch2.tif'], ['test_dir/Cycle05_Ch1.tif', 'test_dir/Cycle05_Ch2.tif'], ['test_dir/Cycle06_Ch1.tif', 'test_dir/Cycle06_Ch2.tif'], ['test_dir/Cycle07_Ch1.tif', 'test_dir/Cycle07_Ch2.tif'], ['test_dir/Cycle08_Ch1.tif', 'test_dir/Cycle08_Ch2.tif'], ['test_dir/Cycle09_Ch1.tif', 'test_dir/Cycle09_Ch2.tif'], ['test_dir/Cycle10_Ch1.tif', 'test_dir/Cycle10_Ch2.tif'], ['test_dir/Cycle11_Ch1.tif', 'test_dir/Cycle11_Ch2.tif'], ['test_dir/Cycle12_Ch1.tif', 'test_dir/Cycle12_Ch2.tif'], ['test_dir/Cycle13_Ch1.tif', 'test_dir/Cycle13_Ch2.tif'], ['test_dir/Cycle14_Ch1.tif', 'test_dir/Cycle14_Ch2.tif'], ['test_dir/Cycle15_Ch1.tif', 'test_dir/Cycle15_Ch2.tif']]
C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\skimage\filter\__init__.py:6: skimage_deprecation: The `skimage.filter` module has been renamed to `skimage.filters`. This placeholder module will be removed in v0.13.
warn(skimage_deprecation('The `skimage.filter` module has been renamed '
Estimating model parameters.
Estimating displacements for cycle 0
Estimating displacements for cycle 1
Estimating displacements for cycle 2
Estimating displacements for cycle 3
Estimating displacements for cycle 4
Estimating displacements for cycle 5
Estimating displacements for cycle 6
Estimating displacements for cycle 7
Estimating displacements for cycle 8
Estimating displacements for cycle 9
Estimating displacements for cycle 10
Estimating displacements for cycle 11
Estimating displacements for cycle 12
Estimating displacements for cycle 13
Estimating displacements for cycle 14
Output filenames:
[[['test_dir/Cycle01_Ch1_corrected.tif', 'test_dir/Cycle01_Ch2_corrected.tif']], [['test_dir/Cycle02_Ch1_corrected.tif', 'test_dir/Cycle02_Ch2_corrected.tif']], [['test_dir/Cycle03_Ch1_corrected.tif', 'test_dir/Cycle03_Ch2_corrected.tif']], [['test_dir/Cycle04_Ch1_corrected.tif', 'test_dir/Cycle04_Ch2_corrected.tif']], [['test_dir/Cycle05_Ch1_corrected.tif', 'test_dir/Cycle05_Ch2_corrected.tif']], [['test_dir/Cycle06_Ch1_corrected.tif', 'test_dir/Cycle06_Ch2_corrected.tif']], [['test_dir/Cycle07_Ch1_corrected.tif', 'test_dir/Cycle07_Ch2_corrected.tif']], [['test_dir/Cycle08_Ch1_corrected.tif', 'test_dir/Cycle08_Ch2_corrected.tif']], [['test_dir/Cycle09_Ch1_corrected.tif', 'test_dir/Cycle09_Ch2_corrected.tif']], [['test_dir/Cycle10_Ch1_corrected.tif', 'test_dir/Cycle10_Ch2_corrected.tif']], [['test_dir/Cycle11_Ch1_corrected.tif', 'test_dir/Cycle11_Ch2_corrected.tif']], [['test_dir/Cycle12_Ch1_corrected.tif', 'test_dir/Cycle12_Ch2_corrected.tif']], [['test_dir/Cycle13_Ch1_corrected.tif', 'test_dir/Cycle13_Ch2_corrected.tif']], [['test_dir/Cycle14_Ch1_corrected.tif', 'test_dir/Cycle14_Ch2_corrected.tif']], [['test_dir/Cycle15_Ch1_corrected.tif', 'test_dir/Cycle15_Ch2_corrected.tif']]]
C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\sima\extract.py:349: UserWarning: Empty ROIs will return all NaN values: 75 empty ROIs found
original_n_rois - n_rois))
Traceback (most recent call last):
File "C:\Users\rylanl\Desktop\segmantation test code.py", line 31, in <module>
dataset.extract(signal_channel='GCaMP', label='GCaMP_signals')
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\sima\imaging.py", line 710, in extract
demix_channel=demix_channel, save_summary=save_summary
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\sima\extract.py", line 520, in save_extracted_signals
signal_channel=signal_channel, **kwargs)
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\sima\extract.py", line 351, in extract_rois
raise ValueError('No valid ROIs found.')
Windows / Anaconda / SIMA 1.2.1
Windows / Winpython / SIMA 1.2.1
Windows / Anaconda / SIMA 1.3.0Linux / Anaconda / SIMA 1.3.0
> <mailto:sima-users+unsub...@googlegroups.com>.
segmentation_approach = sima.segment.STICA()
to
segmentation_approach = sima.segment.STICA(channel='GCaMP')
Still no ROIs. Complete code and the error is below.
Is there anything else I need to change for STICA to operate? For example, do I
need to state the number of PCs to use, specify post-ICA filters or append any
post-processing steps? As far as I can tell (from inserting print statements in
the segmentation code), no post-ICA filters are currently operating. This leads
me puzzled as to how SIMA - as I'm running it currently - converts from ICs to
ROIs.
Code:
from __future__ import print_function
from builtins import input
from builtins import range
import sima
import sima.motion
import sima.segment
tiff_filenames = [['workflow_data/Cycle{n1:02d}_Ch{n2}.tif'.format(n1=cycle, n2=channel) for channel in range(1, 3)] for cycle in range(1, 16)]
sequences = [sima.Sequence.join(*[sima.Sequence.create('TIFF', chan) for chan in cycle]) for cycle in tiff_filenames]
dataset_path = 'workflow_data/dataset.sima'
correction_approach = sima.motion.HiddenMarkov2D(num_states_retained=30, max_displacement=[20, 30])
dataset = correction_approach.correct(sequences, dataset_path, channel_names=['tdTomato', 'GCaMP'], trim_criterion=0.95)
output_filenames = [[[channel.replace('.tif', '_corrected.tif') for channel in cycle]] for cycle in tiff_filenames]
dataset.export_frames(output_filenames, fill_gaps=True)
segmentation_approach = sima.segment.STICA(channel='GCaMP')
dataset.segment(segmentation_approach, 'auto_ROIs')
Error:
C:\Anaconda\lib\site-packages\sima\extract.py:357: UserWarning: Empty ROIs will return all NaN values: 75 empty ROIs found
original_n_rois - n_rois))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile
execfile(filename, namespace)
File "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/jackw/Desktop/testexample_STICA.py", line 134, in <module>
dataset.extract(signal_channel='GCaMP', label='GCaMP_signals')
File "C:\Anaconda\lib\site-packages\sima\imaging.py", line 743, in extract
demix_channel=demix_channel, save_summary=save_summary
File "C:\Anaconda\lib\site-packages\sima\extract.py", line 534, in save_extracted_signals
signal_channel=signal_channel, **kwargs)
File "C:\Anaconda\lib\site-packages\sima\extract.py", line 359, in extract_rois
351
352 rois_to_include = np.array(
353 [idx for idx, mask in enumerate(masks) if mask.nnz > 0])
354 n_rois = len(rois_to_include)
355
Problem fixed. I now have ROIs with STICA and the example data set. Read on for an explanation.
The error originated from line 351 of extract.py and was related to the identification and elimination of overlapping pixels by _identify_overlapping_pixels (lines 327 and 232-250 of extract.py) and _remove_pixels (line 331 and 253-276 of extract.py).
The identification and elimination of overlapping pixels assumes that the incoming masks are binary and the overlapping pixels code identifies and eliminates pixels that are non-zero in more than one mask. The output from STICA is a list of weighed masks. Essentially all pixels in the weighed masks are non-zero. Hence all pixels in all of the masks were eliminated and the code returned no ROIs.
We resolved this by appending the sima.segment.SparseROIsFromMasks method to the STICA segmentation approach:
segmentation_approach = sima.segment.STICA()
segmentation_approach.append(sima.segment.SparseROIsFromMasks())
dataset.segment(segmentation_approach, 'auto_ROIs')
Patrick, I think you weren't able to replicate the error because you didn't call extract.py with your snippet of code.