Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial work on supporting discontiguous data #78

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

palday
Copy link
Member

@palday palday commented Oct 20, 2023

The idea is to provide a separate read_discontiguous to be as backward compatible as possible and to make very clear that something different is happening, namely the gaps are being filled with zeros.

@palday palday marked this pull request as draft October 20, 2023 23:06
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #78 (7868210) into main (2eef49f) will decrease coverage by 10.91%.
The diff coverage is 0.00%.

❗ Current head 7868210 differs from pull request most recent head 75022dc. Consider uploading reports for the commit 75022dc to get more accurate results

@@             Coverage Diff             @@
##             main      #78       +/-   ##
===========================================
- Coverage   95.59%   84.68%   -10.91%     
===========================================
  Files           4        5        +1     
  Lines         295      333       +38     
===========================================
  Hits          282      282               
- Misses         13       51       +38     
Files Coverage Δ
src/EDF.jl 100.00% <ø> (ø)
src/discontiguous.jl 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

src/discontiguous.jl Outdated Show resolved Hide resolved
src/discontiguous.jl Outdated Show resolved Hide resolved
palday and others added 2 commits October 21, 2023 14:23
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@ararslan
Copy link
Member

Alternative, backwards-compatible-ish possibility:

--- a/src/types.jl
+++ b/src/types.jl
@@ -48,20 +48,26 @@ struct SignalHeader
 end

 """
-    EDF.Signal{T}
+    EDF.Signal{T,V}

-Type representing a single EDF signal with sample type `T`.
+Type representing a single EDF signal with sample type `T`, stored in a collection
+of type `V`. For contiguous files (EDF+C), `V === Vector{T}`. For discontiguous files
+(EDF+D), this is `Vector{Vector{T}}`, where the inner vectors are the contiguous samples
+within each data record.

 # Fields

 * `header::SignalHeader`
-* `samples::Vector{T}`
+* `samples::V`
 """
-struct Signal{T}
+struct Signal{T,V<:Union{Vector{T},Vector{Vector{T}}}}
     header::SignalHeader
-    samples::Vector{T}
+    samples::V
 end

+const ContiguousSignal{T} = Signal{T,Vector{T}}
+const DiscontiguousSignal{T} = Signal{T,Vector{Vector{T}}}
+
 Signal{T}(header::SignalHeader) where {T} = Signal(header, T[])
 Signal(header::SignalHeader) = Signal{EDF_SAMPLE_TYPE}(header)

Advantages of this approach:

  • In some sense it's a more direct representation of the "intent" of EDF+D (and is actually a more faithful representation of the underlying data in the file since sample data isn't stored contiguously in the file even for EDF+C)
  • It doesn't require prior knowledge of whether the file is contiguous (which requires reading the header) in order for the user to call the appropriate reading function
  • It doesn't use placeholder data values which may actually be significant for a user's use case
  • Round-tripping a discontiguous file should be easier since you can define separate methods for writing different kinds of signals

@palday
Copy link
Member Author

palday commented Oct 31, 2023

I would probably want both: there are a fair number of downstream tools that making a contiguous assumption in various ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants