Repository navigation
Micromed: read the samples before the first TRONCA entry, put events on the segment clock, read header version 5 - #1966
Open
soheilrayatdoost wants to merge 2 commits into
Conversation
Contributor
|
Thanks @soheilrayatdoost one of us will try to look at this soon. I have a work deadline so I won't be able to look at this for a week, but if someone else on the team can we will follow up. We tend to like to involve as many people in the project as possible so my gut tells me we will probably try to incorporate both this and #1858. |
…ts on the segment clock A TRONCA table lists the segments that follow each cut. When its first trace_offset is above 0 the samples before it are a segment of their own (the recording clock and the data block agree there), but no segment was built for them, so they were never read. Event positions are indices in the data block, the coordinate of trace_offset, while the time axis of a segment starts at its seg_start. Events were placed at start + the first seg_start for every segment, which is right only when seg_start - trace_offset is the same in every entry and the first trace_offset is 0 (as in File_mircomed2_2segments.TRC). They are now placed at seg_start + start - trace_offset, which is the time of their sample. A file without a table, or with a constant offset, reads as before. The tests write their own files, so they need no downloaded data.
Header version 5 has the same layout as version 4 for everything the reader uses. The zone table differs in one detail: the zone names are padded with NULs instead of spaces, so the name check failed even with the version check relaxed.
soheilrayatdoost
force-pushed
the
micromed-tronca-first-segment-and-v5
branch
from
November 9, 2026 16:09
a1b2a37 to
b5b4b86
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1965
MicromedRawIOloses the start of a file that has a TRONCA table, puts its events at the wrong time, and refuses header version 5. The issue has the details and a reproduction that needs no file. Two commits, so that the second can be dropped if #1858 is preferred for version 5.1. The samples before the first
trace_offsetare a segment (first commit)A TRONCA entry is
(seg_start, trace_offset): the sample at indextrace_offsetof the data block is at sampleseg_startof the recording clock, which is the time axis of the segment. Segments were built from the entries only, so when the firsttrace_offsetis above 0 the samples before it belonged to no segment. They now form a first segment starting at time 0, where the clock and the data block agree. A table whose firsttrace_offsetis 0, like the one ofFile_mircomed2_2segments.TRC, gets no extra segment.2. Event times (first commit)
An event
startis an index in the data block, the same coordinate astrace_offset. The time of an event wasstart + seg_startof the first segment, whatever its own segment. It is nowseg_start + start - trace_offsetof the segment that holds it, which is the time of the sample it labels. This only changes files whereseg_start - trace_offsetdiffers between segments or from the firstseg_start, so the existing test files read as before (the table ofFile_mircomed2_2segments.TRCis[(5, 0), (24837, 24832)]: the offset is 5 in both entries).t_startandt_stopofget_event_timestampsuse the same axis.3. Header version 5 (second commit)
The version check accepts 5. The other thing that stopped version 5 files is that their zone names are padded with NULs (
b"IMPED_B\x00") instead of spaces, so the name check raisedexpected the zone name to match; it now strips both. On the version 5 files I have, nothing else was needed: channel names and data equal those of an independent reader (maximum difference 0.0 V over six files). This overlaps #1858, which relaxes the same check. I did not need to skip theIMPED_B/IMPED_Eentries or to seek to 288 for these files, but I can't tell whether the files of #1858 differ from mine. I'm happy to rebase on #1858 or to drop this commit.Tests
TestMicromedSyntheticFileswrites small files withwrite_micromed_trc(no patient data), so it needs no download. 12 tests: the segments and theirt_startfor one cut, two cuts and a table that starts at sample 0, the time of notes, triggers and epochs in each segment,t_start/t_stopfiltering,MicromedIO.read_block, version 5, and that other versions and a wrongly named zone are still refused. On current master the 7 tests of the fixed behaviour fail and the 5 that guard unchanged behaviour pass.TestMicromedRawIOon the three Micromed files of ephy_testing_data passes before and after.dataladis not installed here, so I ran its two tests by hand against local copies of the files.black --line-length 120is clean.