-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better file format detection; Update readme
- Loading branch information
Showing
9 changed files
with
174 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2024 Child Mind Institute | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/// File format identification | ||
/// | ||
/// This module provides a function to identify the file format of a file based on magic numbers. | ||
/// | ||
/// There are also a lot of CSV and other standard file formats used by various manufacturers. | ||
/// These are *not* supported by this library. | ||
/// This library is designed to read binary files that contain raw sensor data. | ||
/// Use any general purpose CSV reader to read these files. | ||
/// Because CSV files do not necessarily contain a unique header we can not identify them from the file contents. | ||
/// | ||
/// Examples of CSV and other standard file formats that are not supported by: | ||
/// - Philips Actiwatch AWD: | ||
/// Uses the AWD file extension, but is a CSV file with 7 lines of header followed | ||
/// by [{time}" , "{activity counts}"\n"] in minute intervals. | ||
/// (Discontinued 2023: https://www.camntech.com/actiwatch-discontinued/ ) | ||
/// - ActiGraph CSV: | ||
/// Note that ActiGraph also has a binary format (GT3X) that *is supported* by this library. | ||
/// - ActiGraph AGD: | ||
/// These are sqlite databases. | ||
/// - ActiWatch MTN: | ||
/// These are XML files. | ||
/// - Axivity WAV: | ||
/// These are WAV audio files. First three channels are X, Y, Z accelerometer data, | ||
/// the fourth is temperature. | ||
/// - Misc. XLS, XLSX, ODS, etc.: | ||
/// These are Microsoft Excel or Open Document Spreadsheets. | ||
/// File formats supported by this library | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum FileFormat { | ||
ActigraphGt3x, | ||
AxivityCwa, | ||
GeneactivBin, | ||
GeneaBin, | ||
// TODO: MovisensBin, These are folders with a bunch of files in them (one called 'acc.bin'). | ||
UnknownWav, | ||
UnknownSqlite, | ||
} | ||
|
||
/// Identify the file format of a file based on its magic number | ||
pub fn identify(magic: &[u8; 4]) -> Option<FileFormat> { | ||
match magic { | ||
b"PK\x03\x04" => Some(FileFormat::ActigraphGt3x), | ||
b"Devi" => Some(FileFormat::GeneactivBin), | ||
[b'M', b'D', ..] => Some(FileFormat::AxivityCwa), | ||
b"GENE" => Some(FileFormat::GeneaBin), | ||
b"RIFF" => Some(FileFormat::UnknownWav), | ||
b"SQLi" => Some(FileFormat::UnknownSqlite), | ||
_ => None, | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ggir | ||
pyactigraphy |
File renamed without changes.
File renamed without changes.