Version 0.5.0 — API improvements and bugfixes
What's Changed
- New
dlmo()function inmarkers.pycomputes DLMO from the rising slope only, returning aDLMOResultwithdlmophase and threshold; raisesValueErrorwith a descriptive message (threshold value and data range) if the waveform never crosses the threshold - New
DLMOResultdataclass with__str__()andto_dict()(timing as HH:MM string); accepted byResultsCollector.add()alongsideSessionInfoandFitResult example_dlmo.pyupdated to usedlmo()and restricted tobcf/sbcf(bimodal functions are not appropriate for onset-only partial data);gen_time_range()call usesfull_day=False- Module docstrings added to all three example scripts
melafit/__init__.py: corrected description of the midpoint markerexample_one_fit.py:collector.add()now includes the fit result (res)- Unit tests added for
DLMOResult,dlmo(), andResultsCollectorintegration withDLMOResult day_profile()gains aninterpparameter (defaultNone) for optional interpolation of empty bins before averaging, useful for sparse raw data- All marker functions (
dlmo,midpoint,area_cog) now accept abinsizeparameter and applyinterp='linear'by default, so sparse inputs are interpolated automatically before phase/marker extraction amplitude()andarea_cog()switch tonp.nanmin/np.nanmaxso input NaNs (e.g. empty Excel cells) are ignored rather than propagated- Unit tests added for interior NaN handling (
TestInteriorNaNHandling) - Fixed a bug in
day_profile()that caused an error when the input data had a sampling period other than 1 minute; the function now correctly handles raw data and fitted curves at any temporal resolution. Combined with the newinterpparameter andbinsizesupport in the marker functions, it is now also possible to extract phase markers directly from raw data without any prior curve fitting or interpolation - Fitting and marker functions (
fit(),amplitude(),dlmo(),midpoint(),area_cog(),day_profile()) now acceptpd.Seriesfor value arguments andpd.Series/pd.DatetimeIndexfor time arguments gen_time_range()switched fromnp.arangeto integer step counting to avoid off-by-one errors from floating-point roundingarea_cog(): baseline fallback tonanminis now computed from the resampled waveform (afterday_profile()) rather than the raw inputarea_cog()andmidpoint()docstrings note the 24 h coverage assumption- Unit tests added:
TestSeriesInput(all new input combinations) andTestMarkersFromRawData(all four markers applied to sparse participant data without curve fitting)
See the README for installation instructions and getting started.