コード例 #1
0
 def test_signal_from_region(self):
     self.fake_region_of_interest()
     seq = ImageSequence(
         self.data,
         units="V",
         sampling_rate=500 * pq.Hz,
         t_start=250 * pq.ms,
         spatial_scale=1 * pq.um,
     )
     signals = seq.signal_from_region(self.rect_ROI)
     self.assertIsInstance(signals, list)
     self.assertEqual(len(signals), 1)
     for signal in signals:
         self.assertIsInstance(signal, AnalogSignal)
         self.assertEqual(signal.t_start, seq.t_start)
         self.assertEqual(signal.sampling_period, seq.frame_duration)
     with self.assertRaises(ValueError):  # no pixels in region
         ImageSequence(
             self.data, units="V", sampling_rate=500 * pq.Hz, spatial_scale=1 * pq.um
         ).signal_from_region(RectangularRegionOfInterest(1, 1, 0, 0))
     with self.assertRaises(ValueError):
         ImageSequence(
             self.data, units="V", sampling_rate=500 * pq.Hz, spatial_scale=1 * pq.um
         ).signal_from_region()
コード例 #2
0
import quantities as pq

import random

# generate data

l = []
for frame in range(50):
    l.append([])
    for y in range(100):
        l[frame].append([])
        for x in range(100):
            l[frame][y].append(random.randint(0, 50))

image_seq = ImageSequence(l,
                          sampling_rate=500 * pq.Hz,
                          spatial_scale='m',
                          units='V')

result = image_seq.signal_from_region(
    CircularRegionOfInterest(50, 50, 25), CircularRegionOfInterest(10, 10, 5),
    PolygonRegionOfInterest((50, 25), (50, 45), (14, 65), (90, 80)))

for i in range(len(result)):
    plt.figure()
    plt.plot(result[i].times, result[i])
    plt.xlabel("seconde")
    plt.ylabel("valeur")

plt.show()