Пример #1
0
    def setup(self):
        global tmp_dir

        self.filepath = os.path.join(tmp_dir, "test_imaging_dataset.sima")
        self.tiff_ds = ImagingDataset(
            [Sequence.create('TIFF', example_tiff(), 1, 1)],
            self.filepath)
Пример #2
0
    def setup(self):
        self.base_seq = sima.Sequence.create("TIFF", example_tiff(), 2, 2)
        self.displacements = np.random.randint(0, 10, self.base_seq.shape[:3] + (2,))

        max_disp = np.amax([np.amax(d.reshape(-1, d.shape[-1]), 0) for d in self.displacements], 0)
        self.final_shape = np.array(self.base_seq.shape)[1:-1]
        self.final_shape[1:3] += max_disp
Пример #3
0
 def test_hmm_missing_frame(self):
     global tmp_dir
     frames = Sequence.create('TIFF', example_tiff())
     masked_seq = frames.mask([(5, None, None)])
     corrected = self.hm2d.correct(
         [masked_seq], os.path.join(tmp_dir, 'test_hmm_3.sima'))
     assert_(all(np.all(np.isfinite(seq.displacements))
                 for seq in corrected))
Пример #4
0
    def setup(self):
        self.tiff_seq = sima.Sequence.create("TIFF", example_tiff(), 2, 2)

        self.tmp_dir = os.path.join(os.path.dirname(__file__), "tmp")

        try:
            os.mkdir(self.tmp_dir)
        except:
            pass
Пример #5
0
 def test_hmm_missing_frame(self):
     global tmp_dir
     frames = Sequence.create('TIFF', example_tiff())
     masked_seq = frames.mask([(5, None, None)])
     corrected = self.hm2d.correct([masked_seq],
                                   os.path.join(tmp_dir, 'test_hmm_3.sima'))
     assert_(
         all(np.all(np.isfinite(seq.displacements)) for seq in corrected))
     assert_(np.prod(corrected.frame_shape) > 0)
Пример #6
0
 def test_hmm_missing_column(self):
     global tmp_dir
     frames = Sequence.create('TIFF', example_tiff())
     mask = np.zeros(frames.shape[1:-1], dtype=bool)
     mask[:, :, 30] = True
     masked_seq = frames.mask([(None, mask, None)])
     corrected = self.hm2d.correct(
         [masked_seq], os.path.join(tmp_dir, 'test_hmm_3.sima'))
     assert_(all(np.all(np.isfinite(seq.displacements))
                 for seq in corrected))
Пример #7
0
 def test_hmm_missing_column(self):
     global tmp_dir
     frames = Sequence.create('TIFF', example_tiff())
     mask = np.zeros(frames.shape[1:-1], dtype=bool)
     mask[:, :, 30] = True
     masked_seq = frames.mask([(None, mask, None)])
     corrected = self.hm2d.correct(
         [masked_seq],
         os.path.join(tmp_dir, 'test_hmm_missing_column.sima'))
     assert_(all(np.all(np.isfinite(seq.displacements))
                 for seq in corrected))
Пример #8
0
 def test_hmm_tmp(self):  # TODO: remove when displacements.pkl is updated
     global tmp_dir
     frames = Sequence.create('TIFF', example_tiff())
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", category=DeprecationWarning)
         corrected = self.hm2d.correct(
             [frames], os.path.join(tmp_dir, 'test_hmm_2.sima'))
     with open(misc.example_data() + '/displacements.pkl', 'rb') as fh:
         displacements = [d.reshape((20, 1, 128, 2))
                          for d in pickle.load(fh)]
     displacements_ = [seq.displacements for seq in corrected]
     assert_(abs(displacements_[0] - displacements[0]).max() <= 1)
Пример #9
0
 def test_hmm_missing_frame(self):
     global tmp_dir
     frames = Sequence.create('TIFF', example_tiff())
     masked_seq = frames.mask([(5, None, None)])
     with warnings.catch_warnings():
         warnings.simplefilter('ignore')
         corrected = self.hm2d.correct(
             [masked_seq], os.path.join(
                 tmp_dir, 'test_hmm_missing_frame.sima'))
     assert_(all(np.all(np.isfinite(seq.displacements))
                 for seq in corrected))
     assert_(np.prod(corrected.frame_shape) > 0)
Пример #10
0
 def test_hmm_tmp(self):  # TODO: remove when displacements.pkl is updated
     global tmp_dir
     frames = Sequence.create('TIFF', example_tiff())
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", category=DeprecationWarning)
         corrected = self.hm2d.correct(
             [frames], os.path.join(tmp_dir, 'test_hmm_2.sima'))
     with open(misc.example_data() + '/displacements.pkl', 'rb') as fh:
         displacements = [d.reshape((20, 1, 128, 2))
                          for d in pickle.load(fh)]
     displacements_ = [seq.displacements for seq in corrected]
     diffs = displacements_[0] - displacements[0]
     assert_(
         ((diffs - diffs.mean(axis=2).mean(axis=1).mean(axis=0)) > 1).mean()
         <= 0.001)
Пример #11
0
    def test_hmm(self):
        global tmp_dir

        frames = Sequence.create('TIFF', example_tiff())
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            corrected = self.hm2d.correct(
                [frames], os.path.join(tmp_dir, 'test_hmm.sima'))

        with open(misc.example_data() + '/displacements.pkl', 'rb') as fh:
            displacements = [d.reshape((20, 1, 128, 2))
                             for d in pickle.load(fh)]

        displacements_ = [seq.displacements for seq in corrected]
        assert_almost_equal(displacements_, displacements)
Пример #12
0
    def test_hmm(self):
        global tmp_dir

        frames = Sequence.create('TIFF', example_tiff())
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            corrected = self.hm2d.correct(
                [frames], os.path.join(tmp_dir, 'test_hmm.sima'))

        with open(misc.example_data() + '/displacements.pkl', 'rb') as fh:
            displacements = [d.reshape((20, 1, 128, 2))
                             for d in pickle.load(fh)]

        displacements_ = [seq.displacements for seq in corrected]
        assert_almost_equal(displacements_, displacements)
Пример #13
0
 def setup(self):
     self.tiff_seq = sima.Sequence.create('TIFF', example_tiff(), 2, 2)
Пример #14
0
    def setup(self):
        global tmp_dir

        self.filepath = os.path.join(tmp_dir, "test_imaging_dataset.sima")
        self.tiff_ds = ImagingDataset(
            [Sequence.create('TIFF', example_tiff(), 1, 1)], self.filepath)
Пример #15
0
 def setup(self):
     self.tiff_seq = sima.Sequence.create('TIFF', example_tiff(), 2, 2)
     self.masked_mask = np.zeros((5, 2, 128, 256, 2), dtype=bool)
Пример #16
0
 def setup(self):
     self.tiff_seq = sima.Sequence.create('TIFF', example_tiff(), 2, 2)
Пример #17
0
 def setup(self):
     self.tiff_seq = sima.Sequence.create('TIFF', example_tiff(), 2, 2)
     self.masked_mask = np.zeros((5, 2, 128, 256, 2), dtype=bool)