edf_rs/headers/
signal_header.rs1#[derive(Debug, Default, Clone, PartialEq)]
2pub struct SignalHeader {
3 pub label: String,
4 pub transducer: String,
5 pub physical_dimension: String,
6 pub physical_minimum: f64,
7 pub physical_maximum: f64,
8 pub digital_minimum: i32,
9 pub digital_maximum: i32,
10 pub prefilter: String,
11 pub samples_count: usize,
12
13 pub(crate) reserved: String,
14}
15
16impl SignalHeader {
17 pub fn new() -> Self {
18 Self::default()
19 }
20
21 pub fn new_annotation(size: usize) -> Self {
22 Self {
23 label: "EDF Annotations".to_string(),
24 transducer: String::new(),
25 physical_dimension: String::new(),
26 digital_minimum: -32768,
27 digital_maximum: 32767,
28 physical_minimum: -1.0,
29 physical_maximum: 1.0,
30 prefilter: String::new(),
31 samples_count: size * 2,
32 reserved: String::new(),
33 }
34 }
35
36 pub fn with_label(&mut self, label: String) -> &mut Self {
37 self.label = label;
38 self
39 }
40
41 pub fn with_transducer(&mut self, transducer: String) -> &mut Self {
42 self.transducer = transducer;
43 self
44 }
45
46 pub fn with_physical_dimension(&mut self, physical_dimension: String) -> &mut Self {
47 self.physical_dimension = physical_dimension;
48 self
49 }
50
51 pub fn with_physical_range(&mut self, min: f64, max: f64) -> &mut Self {
52 self.physical_minimum = min;
53 self.physical_maximum = max;
54 self
55 }
56
57 pub fn with_digital_range(&mut self, min: i32, max: i32) -> &mut Self {
58 self.digital_minimum = min;
59 self.digital_maximum = max;
60 self
61 }
62
63 pub fn with_prefilter(&mut self, prefilter: String) -> &mut Self {
64 self.prefilter = prefilter;
65 self
66 }
67
68 pub fn with_samples_count(&mut self, samples_count: usize) -> &mut Self {
69 self.samples_count = samples_count;
70 self
71 }
72
73 pub fn is_annotation(&self) -> bool {
74 self.label == "EDF Annotations"
75 }
76}