Specification v1.0
Format specification for v1.0
Overview
A squirrel contains a JSON file with meta-data about all of the data in the package, and a directory structure to store files. While many data items are optional, a squirrel package must contain a JSON file and a data directory.
JSON File
JSON is JavaScript object notation, and many tutorials are available for how to read and write JSON files. Within the squirrel format, variable keys are Pascal case; for example DayNumber or DateOfBirth, where each word in the key is capitalized. Keys that hold arrays of child objects are lowercase, with words separated by hyphens; for example subjects, group-analysis, or data-steps. The JSON file should be manually editable. JSON resources:
JSON tutorial - https://www.w3schools.com/js/js_json_intro.asp
JSON specification - https://www.json.org/json-en.html
Data types
The JSON specification includes several data types, but squirrel uses some derivative data types: string, number, date, datetime, char. Date, datetime, and char are stored as the JSON string datatype and should be enclosed in double quotes.
Type
Notes
Example
string
Regular string
“My string of text”
number
Any JSON acceptable number
3.14159 or 1000000
datetime
Datetime is formatted as YYYY-MM-DD HH:MI:SSwhere all numbers are zero-padded and use a 24-hour clock. Datetime is stored as a JSON string datatype
“2022-12-03 15:34:56”
date
Date is formatted as YYYY-MM-DD
“1990-01-05”
char
A single character
F
bool
true or false
true
JSON array
Item is a JSON array of any data type
JSON object
Item is a JSON object
Directory Structure
The JSON file squirrel.json is stored in the root directory. A directory called data contains any data described in the JSON file. Files can be of any type, with file any extension. Because of the broad range of environments in which squirrel files are used, filenames must only contain alphanumeric characters. Filenames cannot contain special characters or spaces and must be less than 255 characters in length.
Squirrel Package
A squirrel package becomes a package once the entire directory structure is combined into a zip file. The compression level does not matter, as long as the file is a .zip archive. Once created, this package can be distributed to other instances of NiDB, squirrel readers, or simply unzipped and manually extracted. Packages can be created manually or exported using NiDB or squirrel converters.
Package Specification
squirrel.db schema
Each package also contains squirrel.db, an SQLite copy of the squirrel.json metadata used to read large packages faster. squirrel.json is authoritative. Each table holds one JSON object type. Most columns have the same name as the JSON variable; the exceptions are listed below. *RowID columns are internal keys linking rows to their parent objects and are not written to JSON.
Table
JSON object
Named differently in JSON
Not written to squirrel.json
Package
Name → PackageName, PackageDataFormat → DataFormat, SubjectDirFormat → SubjectDirectoryFormat, StudyDirFormat → StudyDirectoryFormat, SeriesDirFormat → SeriesDirectoryFormat
JsonHash, FullRead (internal)
Analysis
StartDate → DateStart, EndDate → DateEnd, ClusterStartDate → DateClusterStart, ClusterEndDate → DateClusterEnd, NumSeries → SeriesCount, PipelineRowID → PipelineName
FileCount
Intervention
DateStart → DateInterventionStart, DateEnd → DateInterventionEnd
FrequencyModifier, FrequencyUnit, FrequencyValue
Pipeline
PipelinePrimaryScript, PipelineSecondaryScript (written as primaryScript.sh and secondaryScript.sh)
StagedFiles
—
Internal list of files waiting to be written into the package.