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

Function _write_raw_data

mne/io/base.py:2954–3081  ·  view source on GitHub ↗
(
    raw,
    info,
    picks,
    fid,
    part_idx,
    start,
    stop,
    buffer_size,
    prev_fname,
    split_size,
    next_fname,
    projector,
    drop_small_buffer,
    fmt,
)

Source from the content-addressed store, hash-verified

2952
2953
2954def _write_raw_data(
2955 raw,
2956 info,
2957 picks,
2958 fid,
2959 part_idx,
2960 start,
2961 stop,
2962 buffer_size,
2963 prev_fname,
2964 split_size,
2965 next_fname,
2966 projector,
2967 drop_small_buffer,
2968 fmt,
2969):
2970 # Start the raw data
2971 data_kind = "IAS_" if info.get("maxshield", False) else ""
2972 data_kind = getattr(FIFF, f"FIFFB_{data_kind}RAW_DATA")
2973 start_block(fid, data_kind)
2974
2975 first_samp = raw.first_samp + start
2976 if first_samp != 0:
2977 write_int(fid, FIFF.FIFF_FIRST_SAMPLE, first_samp)
2978
2979 # previous file name and id
2980 if part_idx > 0 and prev_fname is not None:
2981 start_block(fid, FIFF.FIFFB_REF)
2982 write_int(fid, FIFF.FIFF_REF_ROLE, FIFF.FIFFV_ROLE_PREV_FILE)
2983 write_string(fid, FIFF.FIFF_REF_FILE_NAME, prev_fname)
2984 if info["meas_id"] is not None:
2985 write_id(fid, FIFF.FIFF_REF_FILE_ID, info["meas_id"])
2986 write_int(fid, FIFF.FIFF_REF_FILE_NUM, part_idx - 1)
2987 end_block(fid, FIFF.FIFFB_REF)
2988
2989 pos_prev = fid.tell()
2990 if pos_prev > split_size:
2991 raise ValueError(
2992 'file is larger than "split_size" after writing '
2993 "measurement information, you must use a larger "
2994 f"value for split size: {pos_prev} plus enough bytes for "
2995 "the chosen buffer_size"
2996 )
2997
2998 # Check to see if this has acquisition skips and, if so, if we can
2999 # write out empty buffers instead of zeroes
3000 firsts = list(range(start, stop, buffer_size))
3001 lasts = np.array(firsts) + buffer_size
3002 if lasts[-1] > stop:
3003 lasts[-1] = stop
3004 sk_onsets, sk_ends = _annotations_starts_stops(raw, "bad_acq_skip")
3005 do_skips = False
3006 if len(sk_onsets) > 0:
3007 if np.isin(sk_onsets, firsts).all() and np.isin(sk_ends, lasts).all():
3008 do_skips = True
3009 else:
3010 if part_idx == 0:
3011 warn(

Callers 1

writeMethod · 0.85

Calls 9

start_blockFunction · 0.85
write_intFunction · 0.85
write_stringFunction · 0.85
write_idFunction · 0.85
end_blockFunction · 0.85
warnFunction · 0.85
_write_raw_bufferFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected