Ingest Template - Parameters Reference
This is a reference guide for all possible template options as well as example templates.
- pattern
- select
- scan
- packfile_type
- packfile_name
- Variables for configuring Flywheel metadata
- Additional Flywheel metadata you can configure
- Set custom metadata
Pattern
The - pattern
step specifies what Flywheel should do with the top-level folder of level of a directory. The first - pattern:
field in your template corresponds to the parent folder in your dataset directory. Each subsequent - pattern
field in your template walks down each level of folders within that top-level folder.
In general, you need to have a - pattern:
field for each folder in your directory. This is because the template needs instructions for what to do at each folder in the directory.
Valid values for the - pattern:
- Use a variable to set Flywheel labels for group, project, subject, session, acquisition based on the folder name
- Skip that level of the directory by using regex:
.*
- Use
[select](#)
to set different upload instructions if there are multiple folders at the same level. - Use scan to pull out Flywheel labels from a filename instead of folder name or to validate DICOM files
Select
Used to start an expression where you set parameters or logical operators for two folders at the same level of the directory.
You cannot nest a select
statement underneath a select
statement.
The above example packs up all files with the extension .dcm and compresses them into a zip file. The zip file is uploaded with as an acquisition with the acquisitionlabel.dicom.zip
. All other files are ignored and not uploaded.
Scan
Scans can either be filename or dicom. Using scan
is optional, but should be used if you are uploading DICOM data or if you want to parse a filename to use as a metadata label in Flywheel.
You will define the specific scan type below. Below is an example of a complete scan step in the profile:
Name
The name fields configures the type of scan.
Dicom
When the scan
step is set to dicom
, Flywheel reads through all the files within that step of the hierarchy. Flywheel then parses all files with the .dcm
extension. If the file is not a valid DICOM file, the file is not uploaded, and the import stops by default. To determine if a file is valid DICOM, we look for a DICM
string at byte 128.
However, you can use the -force-scan
flag in your CLI command to parse all files as DICOM regardless of the DICM prefix and upload them to Flywheel.
Filename
Use the filename
scan to parse the file names within that step of the directory. This allows you to pull out relevant parts of a filename to create labels and add metadata.
When used in combination with regex, you can loop through all files and use the same piece of the file name string from the files. For example, let's say that all of your images files have been named using the following naming scheme:
1 |
|
The file names would look something like this:
20120215_2340_SUBJ1_acq2.dcm
20120215_2340_SUBJ1_acq3.dcm
20120215_2340_SUBJ1_acq4.dcm
20120215_2340_SUBJ1_acq5.dcm
- etc.
Use the piece of the filename representing the acquisition number acq2, acq3, acq4, to set the acquisition label in Flywheel. To do this for all files the folder, add regex pattern matching along with the Flywheel field name in brackets <>
.
Regex can quickly become complex. You should try out your regex before adding it to your template. See regex101 test out regex.
packfile_type
Groups all files within that level of the the directory, compresses them as a single zip file, and uploads them as an acquisition. You can specify a packfile type for the value. However, it is important to note that this setting does not validate the type of file before adding to the zip. The packfile is added to your acquisition label and becomes the type in the acquisition metadata.
This would result in all files to be uploaded as {acquisition}.png.zip
packfile_name
Overrides the default packfile name. Do not include quotes around the name.
The example above would change the name of the packfile from {acquisition}.dicom.zip
to Historical_data.dicom.zip
Variables for Configuring Flywheel Metadata
The following are the variables used in the template file for Flywheel labels. Use the template variable to map all or part of a file or folder name to the equivalent Flywheel metadata field:
Template variable | Flywheel field |
---|---|
{group}* | group._id |
{project}* | project.label |
{subject} | subject.label |
{session} | session.label |
{acquisition} | acquisition.label |
* While you can use the {group} and {project} variable in your template, whatever you use for the group and project in your command will override whatever is in the template.
Additional Flywheel Metadata that Can Be Configured
- Groups: group.label
- Projects: project.id
- Subjects: subject._id
- Sessions: session._id, session.uid, session.timestamp
- Acquisitions: acquisition._id, acquisition.uid, acquisition.timestamp
Use the following format to assign these fields if you are not using regex:
Set Custom Metadata
You can also set custom metadata in the template. Custom metadata can help you create data views or run analysis. Custom metadata fields following this naming convention: [container].info.[fieldName]
For example, If a custom metadata field called RedCapID
applies to subjects, the field name would look like subject.info.RedCapID
. One example to assign this custom metadata: