msqms.utils.utils module#

Utility functions

Summary#

Functions:#

check_if_directory

fill_zeros_with_nearest_value

find zeros value, interpolate arr with nearest value.

filter

Filter in different ways for different data types

format_timedelta

convert seconds to HH:MM:SS+MS

get_configure

get configuration parameters from configuration file[conf folder].

normative_score

normative score.

read_yaml

Read yaml file

save_yaml

Save a dictionary as a YAML file.

segment_raw_data

The Raw (mne.io.Raw) data is segmented to facilitate metrics calculation.

Reference#

msqms.utils.utils.fill_zeros_with_nearest_value(arr)[source]#

find zeros value, interpolate arr with nearest value.

msqms.utils.utils.format_timedelta(seconds)[source]#

convert seconds to HH:MM:SS+MS

msqms.utils.utils.segment_raw_data(raw, seg_length)[source]#

The Raw (mne.io.Raw) data is segmented to facilitate metrics calculation.

Parameters:
  • raw (mne.io.raw) – the object of MEG data.

  • seg_length (float) – Represents the length of the split (seconds).

Returns:

raw_list[mne.io.raw]

the list of segmented raw.

segment_timeslist

the list of segmented times.

msqms.utils.utils.save_yaml(data, fname_path)[source]#

Save a dictionary as a YAML file.

Parameters:
  • data (dict) – The data to be saved in YAML format.

  • fname_path (str or Path) – The path where the YAML file will be saved.

Return type:

None

Notes

This function will overwrite the file if it already exists.

msqms.utils.utils.read_yaml(yaml_file)[source]#

Read yaml file

Parameters:

yaml_file (str | Path) – the path of the yaml file.

Returns:

content – the contents of the yaml file.

Return type:

dict

msqms.utils.utils.get_configure(data_type)[source]#

get configuration parameters from configuration file[conf folder].

Return type:

Dict

Parameters:

data_type (DATA_TYPE) – the data type of MEG.(‘opm’ or ‘squid’)

Returns:

the dict of configuration parameters,including ‘default’ and ‘data_type’.

msqms.utils.utils.normative_score(num, thres=20)[source]#

normative score.

msqms.utils.utils.check_if_directory(path)[source]#
msqms.utils.utils.filter(raw, high_pass, low_pass, notch_freq, data_type, pad_length=10, n_jobs=-1, verbose=True)[source]#

Filter in different ways for different data types

Return type:

RawArray | Any

Parameters:
  • raw (mne.io.Raw)

  • data_type (Data_TYPE) – the data type of MEG.(‘opm’ or ‘squid’)

  • high_pass (float) – the high pass frequency.

  • low_pass (float) – the low pass frequency.

  • notch_freq (list[float]) – the notch filter frequency.

  • pad_length (int) – the padding of data before filtering (seconds),`reflect` fill before and after the data.

  • n_jobs (int) – the number of jobs.

Returns:

the filtered raw