Пример #1
0
def test_beam_io_runs():
    cr = MEG_coreg("asdf", "fdsa", np.eye(4), np.eye(3))
    b = Beam(np.array([5.0] * 3), np.random.randn(1000, 3), 200.0, np.arange(100), np.random.randn(1000), cr)
    f = tempfile.mktemp(suffix=".npy")
    try:
        b.save(f)
        b2 = Beam.load(f)
        os.unlink(f)
        assert True
    except:
        os.unlink(f)
        assert False, "simple Beam I/O failed"
Пример #2
0
    def __init__(self, voxelsize, voxels, srate, timepts,
                 sig, coreg, bands, timewindow,
                 coordmap=None, fixed_comparison=None, uses='F dB'):
        """
        Parameters
        ----------
        voxelsize : len-3 iterable
          the voxel edge lengths
        voxels : ndarray shaped (nvox, 3)
          the voxel coordinates, in this Beam's target coordinate space
        srate : float
          the sampling rate of the MEG time series
        timepts : ndarray
          the sample times
        sig : ndarray
          the MEG signal data -- see NOTE
        coreg : MEG_coreg object
          the MEG-to-MRI coregistration info
        coordmap : NIPY AffineTransform object
          the MEG voxel index coordinate to voxel location coordinate mapping

        Notes
        -----
        The signal argument can take on the following forms:
        * a record/structured ndarray with 'active', 'control', ['noise']
          components
        * a list/tuple of ndarrays (taken to mean 'active', 'control',
          ['noise'] components)
        * a normal ndarray with no separate components (literally, a
          fixed comparison). In this case, the `fixed_comparison` keyword
          argument is REQUIRED so that the TFBeam understands what the
          data means
        * adapted from MATLAB s_beam*.mat files, for `internal` use --
          This format has dtype('object'), and may be a simple list of
          components

        """
        sig, voxels = self._init_signal(sig, voxels, fixed_comparison)
        Beam.__init__(self, voxelsize, voxels, srate, timepts, sig, coreg,
                      coordmap=coordmap)
        self.bands = np.atleast_2d(bands)
        self.timewindow = np.atleast_2d(timewindow)
        if not fixed_comparison:
            # still mark it down for posterity (ie, array "pickling")
            self.fixed_comparison = fixed_comparison
            self.uses = uses
        else:
            self.fix_comparison(fixed_comparison)