Skip to content

EdfHeader Suggestions #1

@DerAndereJohannes

Description

@DerAndereJohannes

Hi! Thank you for taking the time to implement edfplus. It is exactly what I just needed :-)

I only had a short time to look at it, but I wanted to give two suggestions to make the library a bit more friendly to use.

1. Add the Clone derive to the EdfHeader

Since the reader in its current form needs to be mutable (is there a reason for this btw?), trying to keep the header information while using the read_physical_samples is not that easy and the solution in the example is not that ideal to me (as from the example):

let header_info = {
    let header = reader.header();
    (
        header.signals.len(),
        header.file_duration,
        header.datarecords_in_file,
        header.datarecord_duration,
        header.patient_code.clone(),
        header.sex.clone(),
        header.birthdate.clone(),
        header.patient_name.clone(),
        header.start_date,
        header.start_time,
        header.equipment.clone(),
        header.technician.clone(),
        header.signals.clone(),
    )
};

Just add a Clone derive on the EdfHeader such that you can replace the above with:

let header_info = reader.header().clone();

2. samples_in_file in SignalParam should be of type usize instead of i64

sample length cannot be negative and it is very typical for lengths to be stored as usize and are usually used for length based values ((1..10).len(); also returns a usize of 9).

This would make your reader.read_physical_samples(0, h_signal.samples_in_file); look a lot nicer than having to do type conversion between i64 to usize.

I feel both these changes would already go a long way. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions