@@ -68,34 +68,23 @@ def check_timestamps_ascending(time_series: TimeSeries, nelems=200):
6868 return InspectorMessage (f"{ time_series .name } timestamps are not ascending." )
6969
7070
71+ @register_check (importance = Importance .BEST_PRACTICE_VIOLATION , neurodata_type = TimeSeries )
72+ def check_missing_unit (time_series : TimeSeries ):
73+ """
74+ Check if the TimeSeries.unit field is empty.
75+
76+ Best Practice: :ref:`best_practice_unit_of_measurement`
77+ """
78+ if not time_series .unit :
79+ return InspectorMessage (
80+ message = "Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'."
81+ )
82+
83+
7184@register_check (importance = Importance .BEST_PRACTICE_VIOLATION , neurodata_type = TimeSeries )
7285def check_resolution (time_series : TimeSeries ):
7386 """Check the resolution value of a TimeSeries for proper format (-1.0 or NaN for unknown)."""
7487 if time_series .resolution != - 1.0 and time_series .resolution <= 0 :
7588 return InspectorMessage (
7689 message = f"'resolution' should use -1.0 or NaN for unknown instead of { time_series .resolution } ."
7790 )
78-
79-
80- # TODO: break up logic of extra stuff into separate checks
81- # def check_timeseries(nwbfile):
82- # """Check dataset values in TimeSeries objects"""
83- # for ts in all_of_type(nwbfile, pynwb.TimeSeries):
84- # if ts.data is None:
85- # # exception to the rule: ImageSeries objects are allowed to have no data
86- # if not isinstance(ts, pynwb.image.ImageSeries):
87- # error_code = "A101"
88- # print("- %s: '%s' %s data is None" % (error_code, ts.name, type(ts).__name__))
89- # else:
90- # if ts.external_file is None:
91- # error_code = "A101"
92- # print(
93- # "- %s: '%s' %s data is None and external_file is None"
94- # % (error_code, ts.name, type(ts).__name__)
95- # )
96- # continue
97-
98- # if not ts.unit:
99- # error_code = "A101"
100- # print("- %s: '%s' %s data is missing text for attribute 'unit'"
101- # % (error_code, ts.name, type(ts).__name__))
0 commit comments