-
Notifications
You must be signed in to change notification settings - Fork 62
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
Allow part 5 to export time series even if there is only one night of data. #895
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## master #895 +/- ##
==========================================
- Coverage 78.09% 78.01% -0.08%
==========================================
Files 91 91
Lines 12118 12138 +20
==========================================
+ Hits 9463 9469 +6
- Misses 2655 2669 +14
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything works well. I run this in a short file and I got the timeseries. Also, I noticed that the part 5 clean report (daysummary) is generated even if it is empty (0 rows of data). It is expected to be empty as the recording is too short for part 5 analyses, but should we avoid generating this file? The full daysummary report within QC folder looks fine.
R/g.part5.R
Outdated
@@ -163,7 +163,7 @@ g.part5 = function(datadir = c(), metadatadir = c(), f0=c(), f1=c(), | |||
di = 1 | |||
fi = 1 | |||
SPTE_end = c() # if it is not loaded from part3 milestone data then this will be the default | |||
if (length(idindex) > 0 & nrow(summarysleep) > 1) { #only attempt to load file if it was processed for sleep | |||
if (length(idindex) > 0 & nrow(summarysleep) > 0) { #only attempt to load file if it was processed for sleep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update the comment in this line to # 2023-09-08: to load file as long as it has 1 night available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, but adding the date is not needed because the commit itself already has a timestamp and it reduces readability to dates in the code. I am now updating the comment.
@@ -61,6 +61,7 @@ g.part5.addsib = function(ts, epochSize, part3_output, desiredtz, sibDefinition, | |||
redo1 = nightsi[1] - ((60/epochSize)*60) # 1 hour before first midnight | |||
if (redo1 < 1) redo1 = 1 | |||
redo2 = nightsi[1] + (14*(60/epochSize)*60) # 14 hours after first midngiht | |||
if (redo2 > Nts) redo2 = Nts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this can interact with my changes in #892. I don't think so, but maybe it is safer to merge the two branches and test them together before merging them into master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just merged all in this PR. The exporting of the short time series file still works.
Note that this line only checks that redo2 is not beyond the end of the measurement because the line before potentially incorrectly assumes that there is always 14 hours extract after the first night. If it is then the new line clips redo2 to the number of rows in ts (Nts). So, this should not do any harm.
@jhmigueles Would you mind testing this branch again with the files you used to test #892 to make sure that functionality is not broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did it and everything works well.
For me no day or recordings level part5 csv reports are created, only the time series files in ms5.outraw. Could you share more details on your short recording or send me the part1 output + your script to reproduce it? |
I just did this:
And I got the file "results/part5_daysummary_MM_L40M100V400_T5A5.csv" generated, containing only the column names (not a big problem as there are no data in the file anyway). |
Thanks, I managed to reproduce it and made a minor edit to prevent g.report.part5 from storing the csv files if there are no rows. |
In this PR:
Checklist before merging:
inst/NEWS.Rd
with a user-readable summary. Please, include references to relevant issues or PR discussions.DESCRIPTION
andCITATION.cff
files.