API Reference#
- exception nkpy.CorruptionError#
Exception raised when reading an Excel file fails.
This is fixed by opening the file with Excel manually and saving it with no modifications (CTRL+S).
- class nkpy.EEGFile(path, start, end, exam_number)#
Represent an eeg file in the Nihon Kohden’s NeuroWorkbench database.
These do not need to be created manually, and are instead returned by the
read_excel()
andread_excels()
functions.- Parameters:
path (Path)
start (datetime)
end (datetime)
exam_number (str)
- path#
Full path to the eeg file.
- Type:
- start#
Start time of the recording.
- Type:
- end#
End time of the recording.
- Type:
- class nkpy.Patient(patient_id, patient_name, sex, birth_date, eegs=<factory>, videos=<factory>)#
Represent a patient in the Nihon Kohden’ NeuroWorkbench database.
These do not need to be created manually, and are instead returned by the
read_excel()
andread_excels()
functions.- Parameters:
- birth_date#
The date of birth of the patient.
- Type:
- class nkpy.VideoFile(path, start, end, clipped)#
Represent a video file in the Nihon Kohden’s NeuroWorkbench database.
These do not need to be created manually, and are instead returned by the
read_excel()
andread_excels()
functions.- Parameters:
path (Path)
start (datetime)
end (datetime)
clipped (bool)
- path#
Full path to the video file.
- Type:
- start#
Start time of the recording.
- Type:
- end#
End time of the recording.
- Type:
- nkpy.get_patient_eegs(patient, before=None, after=None)#
Select the eegs from a
Patient
that are within a time range.- Parameters:
patient (Patient) – The
Patient
object from which we want to select theEEGFile
.before (
datetime.datetime
|None
, optional) – Thedatetime.datetime
which we want the eegs that are before that moment. IfNone
, select all eegs up to the end of the recordings. By defaultNone
.after (
datetime.datetime
|None
, optional) – Thedatetime.datetime
which we want the eegs that are after that moment. IfNone
, select all eegs from the start of the recordings. By defaultNone
.
- Returns:
List of the selected
EEGFile
.- Return type:
list[
EEGFile
]
- nkpy.get_patient_videos(patient, before=None, after=None)#
Select the videos from a
Patient
that are within a time range.- Parameters:
patient (
Patient
) – ThePatient
object from which we want to select theVideoFile
.before (
datetime.datetime
|None
, optional) – Thedatetime.datetime
which we want the videos that are before that moment. IfNone
, select all videos up to the end of the recordings. By defaultNone
.after (
datetime.datetime
|None
, optional) – Thedatetime.datetime
which we want the videos that are after that moment. If No``None``ne, select all videos from the start of the recordings. By defaultNone
.
- Returns:
List of the selected
VideoFile
.- Return type:
list[
VideoFile
]
- nkpy.read_excel(filename)#
Read an Excel sheet exported from Nihon Kohden’s NeuroWorkbench
- Parameters:
filename (
str
|pathlib.Path
) – The path to the Excel file, exported from NeuroWorkbench.- Returns:
A dictionnary of patient IDs to
Patient
objects.- Return type:
- Raises:
CorruptionError – Can happen in some cases where the Excel file cannot be read. It can be fixed by opening the file in Excel, and saving it as-is (CTRL+S).
- nkpy.read_excels(*filenames)#
Read multiple Excel files exported from Nihon Kohden’s NeuroWorkbench and return the data into a single PatientDict.
- Parameters:
*filenames (
str
|pathlib.Path
) – A sequence of paths to the Excel files, exported from NeuroWorkbench.- Returns:
A dictionnary of patient IDs to
Patient
objects.- Return type:
- Raises:
CorruptionError – Can happen in some cases where the Excel file cannot be read. It can be fixed by opening the file in Excel, and saving it as-is (CTRL+S).