MCPcopy
hub / github.com/mne-tools/mne-python / _RawFidWriter

Class _RawFidWriter

mne/io/base.py:2898–2951  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2896
2897
2898class _RawFidWriter:
2899 def __init__(self, raw, info, picks, projector, start, stop, cfg):
2900 self.raw = raw
2901 self.picks = _picks_to_idx(info, picks, "all", ())
2902 self.info = pick_info(info, sel=self.picks, copy=True)
2903 for k in range(self.info["nchan"]):
2904 # Scan numbers may have been messed up
2905 self.info["chs"][k]["scanno"] = k + 1 # scanno starts at 1 in FIF format
2906 if cfg.reset_range:
2907 self.info["chs"][k]["range"] = 1.0
2908 self.projector = projector
2909 # self.start is the only mutable attribute in this design!
2910 self.start, self.stop = start, stop
2911 self.cfg = cfg
2912
2913 def write(self, fid, part_idx, prev_fname, next_fname):
2914 self._check_start_stop_within_bounds()
2915 start_block(fid, FIFF.FIFFB_MEAS)
2916 _write_raw_metadata(
2917 fid,
2918 self.info,
2919 self.cfg.data_type,
2920 self.cfg.reset_range,
2921 self.raw.annotations,
2922 )
2923 self.start = _write_raw_data(
2924 self.raw,
2925 self.info,
2926 self.picks,
2927 fid,
2928 part_idx,
2929 self.start,
2930 self.stop,
2931 self.cfg.buffer_size,
2932 prev_fname,
2933 self.cfg.split_size,
2934 next_fname,
2935 self.projector,
2936 self.cfg.drop_small_buffer,
2937 self.cfg.fmt,
2938 )
2939 end_block(fid, FIFF.FIFFB_MEAS)
2940 is_next_split = self.start < self.stop
2941 return is_next_split
2942
2943 def _check_start_stop_within_bounds(self):
2944 # we've done something wrong if we hit this
2945 n_times_max = len(self.raw.times)
2946 error_msg = (
2947 f"Can't write raw file with no data: {self.start} -> {self.stop} "
2948 f"(max: {n_times_max}) requested"
2949 )
2950 if self.start >= self.stop or self.stop > n_times_max:
2951 raise RuntimeError(error_msg)
2952
2953
2954def _write_raw_data(

Callers 1

saveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected