def test_metric_decoding_without_spots(): codebook, image_stack, max_intensity = two_spot_sparse_coded_data_factory() bd = starfish.spots.DetectSpots.BlobDetector(min_sigma=1, max_sigma=1, num_sigma=1, threshold=max_intensity + 0.1) no_spots = bd.run(image_stack) decode = starfish.spots.Decode.MetricDistance(codebook, max_distance=0, min_intensity=max_intensity + 0.1) decoded_no_spots: starfish.IntensityTable = decode.run(no_spots) decoded_spot_table = decoded_no_spots.to_decoded_spots() with TemporaryDirectory() as dir_: filename = os.path.join(dir_, 'test.csv') decoded_spot_table.save_csv(os.path.join(dir_, 'test.csv')) # verify we can concatenate two empty tables table1 = pd.read_csv(filename, index_col=0) table2 = pd.read_csv(filename, index_col=0) pd.concat([table1, table2], axis=0)
def test_per_round_max_spot_decoding_without_spots(tmpdir): codebook, image_stack, max_intensity = two_spot_sparse_coded_data_factory() bd = starfish.spots.FindSpots.BlobDetector(min_sigma=1, max_sigma=1, num_sigma=1, threshold=max_intensity + 0.1) no_spots = bd.run(image_stack) decode = starfish.spots.DecodeSpots.PerRoundMaxChannel(codebook) decoded_no_spots: starfish.DecodedIntensityTable = decode.run( spots=no_spots) decoded_spot_table = decoded_no_spots.to_decoded_dataframe() filename = os.path.join(tmpdir, 'test.csv') decoded_spot_table.save_csv(os.path.join(tmpdir, 'test.csv')) # verify we can concatenate two empty tables table1 = pd.read_csv(filename, index_col=0) table2 = pd.read_csv(filename, index_col=0) pd.concat([table1, table2], axis=0)
from starfish import ImageStack from starfish.core.spots.DecodeSpots import trace_builders from starfish.core.spots.FindSpots import BlobDetector from starfish.core.spots.FindSpots import FindSpotsAlgorithm from starfish.core.test.factories import ( two_spot_informative_blank_coded_data_factory, two_spot_one_hot_coded_data_factory, two_spot_sparse_coded_data_factory, ) from starfish.types import Axes, Features, FunctionSource # verify all spot finders handle different coding types _, ONE_HOT_IMAGESTACK, ONE_HOT_MAX_INTENSITY = two_spot_one_hot_coded_data_factory() _, SPARSE_IMAGESTACK, SPARSE_MAX_INTENSITY = two_spot_sparse_coded_data_factory() _, BLANK_IMAGESTACK, BLANK_MAX_INTENSITY = two_spot_informative_blank_coded_data_factory() # make sure that all spot finders handle empty arrays EMPTY_IMAGESTACK = ImageStack.from_numpy(np.zeros((4, 2, 10, 100, 100), dtype=np.float32)) def simple_gaussian_spot_detector() -> BlobDetector: """create a basic gaussian spot detector""" return BlobDetector( min_sigma=1, max_sigma=4, num_sigma=5, threshold=0, measurement_type='max')