Bulk Import - Customizing Import Rules
Overview
While Flywheel provides automatic import behavior that works well for many scenarios, you may need to customize how files are organized during import.
The new (BETA) CLI provides extensive options for customizing:
- Filtering - Control which files are imported
- Mapping - Define how files are organized into Flywheel's hierarchy
- Grouping - Control how DICOM files are packaged into ZIP archives
- File Naming - Customize ZIP archive and individual file names
All customization options are available when using the fw-beta import run command.
Pattern Syntax Documentation
For comprehensive pattern syntax documentation and practical examples, see:
- Filtering and Mapping Guide - Practical examples and common use cases
- Pattern Quick Reference - Quick lookup for common patterns
- Pattern Syntax Reference - Complete syntax documentation
- Rule Files - Define complex rules in reusable YAML format
Filtering Files
Filters control which files are included or excluded from import based on file properties like name, size, path, or depth.
Include Filters
Include filters specify which files should be processed. At least one include filter must match for a file to be imported.
Exclude Filters
Exclude filters specify which files should be skipped. If any exclude filter matches, the file is not imported.
Combining Include and Exclude
For more filtering examples and available fields, see the Filtering and Mapping Guide.
Mapping Files to Flywheel Hierarchy
Mapping patterns define how source file paths are transformed into Flywheel's hierarchy structure (Subject, Session, Acquisition) and how container labels are derived.
Path-Based Mapping
Extract container labels from file path structure:
DICOM Metadata Mapping
For DICOM files, derive container labels from DICOM headers:
Default Values
Set default values when mappings don't extract a value:
Override Values
Force specific values regardless of extracted data:
For more mapping examples and available DICOM fields, see the Filtering and Mapping Guide.
DICOM-Specific Customizations
Custom Grouping Logic
Control how DICOM files are grouped into ZIP archives using the --dicom-group-by option:
Disable Zipping Single Files
By default, even single DICOM files are zipped. Use --no-zip-single to disable this:
Configuring File Names
Control the naming of files during import using the file.name mapping field. This applies to both ZIP archives created from DICOM files and non-DICOM files:
Configuring Individual DICOM File Names
Control how individual DICOM files are named within ZIP archives using --dicom-instance-name:
Note
The --dicom-instance-name option only affects DICOM files packaged into ZIP archives. To customize the names of loose DICOM files when --no-zip-single is used, use the file.name mapping field instead (see Configuring File Names).
Using Rule Files
For complex import scenarios with multiple sets of rules, you can define all your customizations in a reusable YAML rule file:
Rule files support:
- Multiple rules with first-match-wins logic
- All filtering and mapping options
- DICOM-specific configurations
- Reusable configurations across imports
See Rule Files for complete documentation on the YAML format and examples.
Complete Example
Here's a comprehensive example combining multiple customization options:
This command:
- Imports DICOM files larger than 1MB
- Excludes localizer and scout images
- Derives container labels from DICOM headers
- Groups files by study and series
- Customizes individual DICOM file naming within archives
Testing Your Configuration
Before running a full import, test your configuration using:
See Also
- Bulk Import - Default Behavior - Understanding automatic import processing
- Bulk Import - How-To (CLI) - Step-by-step import process
- Pattern Syntax Reference - Complete pattern syntax documentation
- Rule Files - Define complex rules in YAML format
- fw-beta CLI Documentation - Complete CLI reference