Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting signals from weighted ROIs fails #140

Open
neurodroid opened this issue Mar 24, 2015 · 3 comments
Open

Extracting signals from weighted ROIs fails #140

neurodroid opened this issue Mar 24, 2015 · 3 comments

Comments

@neurodroid
Copy link
Contributor

Weighted ROIs, as returned by sima.segment.STICA, cannot be used for signal extraction. Using r178576528. Minimal standalone sample to reproduce the issue:

import sima
import sima.segment
import sima.misc
from shutil import copy, copytree

copytree(sima.misc.example_data(), 'example.sima')
copy(sima.misc.example_tiff(), 'example.tif')

dataset = sima.ImagingDataset.load('example.sima')

# The following works, indicating that the ROIs are not "empty":
stica_sparse_approach = sima.segment.STICA(components=19, verbose=True)
stica_sparse_approach.append(sima.segment.SparseROIsFromMasks())
stica_sparse_rois = dataset.segment(stica_sparse_approach, 'stica_sparse_ROIs')
signals = dataset.extract(stica_sparse_rois, signal_channel='green', 
    label='green_signal_stica_sparse')

# The following fails
stica_approach = sima.segment.STICA(components=19, verbose=True)
stica_rois = dataset.segment(stica_approach, 'stica_ROIs')
signals = dataset.extract(stica_rois, signal_channel='green', label='green_signal_stica')

Relevant messages:

UserWarning: Empty ROIs will return all NaN values: 19 empty ROIs found
ValueError: No valid ROIs found.
@pkaifosh
Copy link
Member

Thanks for this bug report of exemplary clarity.

The extract method has a remove_overlap argument that defaults to True, causing it to remove all overlapping pixels are common to more than one ROI. In the case of mask ROIs, which have values for all pixels, this removes everything.

The error goes away if you change the value of this argument to be False:

signals = dataset.extract(stica_rois, signal_channel='green', label='green_signal_stica', remove_overlap=False)

@jzaremba @nbdanielson Would you object to changing the default value for remove_overlap to be False?

@jzaremba
Copy link
Member

I'm somewhat hesitant to change the default behavior, not removing overlapping pixels can actually have a fairly substantial effect on your signals if you expected them to have been removed.

That being said, I'm not sure you'd ever want to remove overlapping pixels for non-boolean masks. We could just disable that ability entirely and throw a warning if you try it?

@neurodroid
Copy link
Contributor Author

That being said, I'm not sure you'd ever want to remove overlapping pixels for non-boolean masks. We could just disable that ability entirely and throw a warning if you try it?

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants