Writer
Write validated data into sleeplab format.
The data needs to conform to the types specified in
sleeplab_format.models.
write_dataset(dataset, basedir, annotation_format='json', array_format='numpy', compression_level=9)
Write a SLF dataset to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
A sleeplab_format.models.Dataset. |
required |
basedir
|
str
|
The folder where the dataset will be saved. |
required |
annotation_format
|
str
|
The format of the annotation files. |
'json'
|
array_format
|
str
|
The format of the sample array data files. |
'numpy'
|
compression_level
|
int
|
The zstd compression level if |
9
|
Source code in src/sleeplab_format/writer.py
write_series(series, series_path, annotation_format='json', array_format='numpy', compression_level=9)
Write a sleeplab_format.models.Series to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
series
|
Series
|
The sleeplab_format.models.Series to save. |
required |
series_path
|
Path
|
The path to the folder where the series will be saved. |
required |
annotation_format
|
str
|
The format of the annotation files. |
'json'
|
array_format
|
str
|
The format of the sample array data files. |
'numpy'
|
compression_level
|
int
|
The zstd compression level if |
9
|
Source code in src/sleeplab_format/writer.py
write_subject(subject, subject_path, annotation_format='json', array_format='numpy', compression_level=9)
Write a single Subject to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
Subject
|
A sleeplab_format.models.Subject to save. |
required |
subject_path
|
Path
|
Path to the subject save folder. |
required |
annotation_format
|
str
|
The format of annotation files. |
'json'
|
array_format
|
str
|
The format of the sample array data files. |
'numpy'
|
compression_level
|
int
|
The zstd compression level if |
9
|
Source code in src/sleeplab_format/writer.py
write_annotations(subject, subject_path, format='json')
Write SLF annotations to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
Subject
|
A sleeplab_format.models.Subject whose annotations will be written. |
required |
subject_path
|
Path
|
The path to the subject folder. |
required |
format
|
str
|
The format of annotation files. |
'json'
|
Source code in src/sleeplab_format/writer.py
write_sample_arrays(subject, subject_path, format='numpy', zarr_chunksize=5000000.0, zarr_compression_level=9)
Write all sample arrays of the subject.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
Subject
|
The sleeplab.models.Subject instance. |
required |
subject_path
|
Path
|
Path to the folder where the sample arrays are saved. |
required |
format
|
str
|
The save format for the numerical arrays; |
'numpy'
|
zarr_chunksize
|
int | None
|
The chunk size in bytes if |
5000000.0
|
zarr_compression_level
|
int
|
The compression level used with the Zstandard compression. |
9
|
Source code in src/sleeplab_format/writer.py
write_subject_metadata(subject, subject_path)
Write subject metadata to JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
Subject
|
The sleeplab_format.models.Subject whose metadata will be saved. |
required |
subject_path
|
Path
|
The path to the subject folder. |
required |