Source Tree Map
A guided tour of every package in src/main/groovy/nfneuro/, what each one owns, and how the packages relate to one another.
The source tree and the compiled JAR share a common pattern: the filesystem path omits the plugin segment, but every class declares the full nfneuro.plugin.* package.
Directory ↔ Package Mapping
The root of the Groovy source tree is src/main/groovy/nfneuro/.
Each sub-directory corresponds to one package segment after the implicit nfneuro.plugin prefix.
| Directory | Java package | Top-level classes |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Package Responsibilities
nfneuro.plugin — Plugin Bootstrap
This package is the Nextflow integration layer. The four classes in it form the minimal surface that Nextflow’s pf4j plugin loader requires.
BidsPlugin-
Extends
nextflow.plugin.BasePlugin. Its sole job is to be discovered by pf4j via the plugin descriptor. It carries no domain logic. BidsExtension-
Extends
PluginExtensionPointand declares the public API: the@FactorymethodfromBIDS()and the three@OperatormethodsgroupTupleBy(),joinBy(), andcombineBy(). All factory and operator implementations are delegated toBidsChannelFactoryand the*Opclasses respectively. BidsFactory-
Implements
TraceObserverFactory. Itscreate(Session)method instantiates aBidsObserverand registers it with the Nextflow trace system. BidsObserver-
Implements
TraceObserver. Currently prints a startup banner ononFlowCreateand a completion message ononFlowComplete. This is the hook point for future workflow-level observability.
See Plugin Bootstrap for the pf4j lifecycle.
nfneuro.plugin.channel — Channel Assembly
Two classes orchestrate the entire Channel.fromBIDS() pipeline.
BidsChannelFactory-
Receives the
Sessionat construction and exposesfromBIDS(String bidsDir, String configPath, Map options). It runs pre-flight validation (directory existence, config file existence, optionallibbids_shpath) and then constructs aBidsHandlerusing the fluent builder API. BidsHandler-
The stateful orchestrator. It holds the parsed configuration, the list of
loopOverEntities, thesuffixMapping, and theBidsParser.ignite(Session)creates theDataflowWriteChannel, registers an async igniter for DSL2 execution, and returns the channel.execute()callsparser.parseToDataset(), routes files through the appropriate set-handler subclass, applies cross-modal broadcasting, and emits items onto the channel. The channel is closed withChannel.STOPafter all items are emitted.
nfneuro.plugin.channel.operations — Closure Operators
Each *Op class is a self-contained operator implementation.
GroupTupleByOp-
Groups channel items by a closure-extracted key, accumulating items in a synchronized
Map<Object, List>and emitting[key, [items]]tuples. JoinByOp-
Performs an inner join between two channels using independent key-extractor closures for left and right sides. Supports
remainderand duplicate-handling options, emitting fused join payloads without keys. CombineByOp-
Emits the Cartesian product of left and right items within each key group as fused payloads (key omitted).
BidsExtensionprovides three overloads to support a single shared extractor or separate left/right extractors.
nfneuro.plugin.channel.operations.keys — Key Infrastructure
KeyExtractor-
Static utility that safely invokes a key-extractor closure on a channel item. It normalises
List-valued keys by wrapping them in aCompositeKeyso thatMaplookups use value equality rather than reference equality. CompositeKey-
An
@EqualsAndHashCode-annotated wrapper for multi-part keys (e.g.,[subject, session]). Without this class, two distinctListinstances with identical contents would hash differently in aHashMap.
nfneuro.plugin.parser — BIDS Parsing
BidsParser-
Orchestrates the two-step parse: calls
LibBidsShWrapper.parseBidsToTable()to obtain a TSV file, then passes it toBidsCsvParser(inutil). Returns a fully populatedBidsDataset. LibBidsShWrapper-
Bridges Groovy and the external
libBIDS.shbash library. Implements a priority-ordered discovery chain: plugin-embeddedlib/libBIDS.shfirst, then several relative paths, then system paths (/usr/local/bin,~/.local/bin). Executes the script using an array-form command (bash -c 'set -euo pipefail && source …') to prevent shell injection. See The libBIDS.sh Dependency for the full discovery order. BidsValidator-
A stub — BIDS validation via
bids-validatoris deferred to v1.1. The class exists butvalidate()logs a warning and returns immediately. Validation code inBidsChannelFactoryis commented out.
nfneuro.plugin.config — Configuration Layer
BidsConfigLoader-
Loads a YAML file with SnakeYAML, rejects the reserved key
meta, and delegates structural validation toBidsConfigValidator. BidsConfigValidator-
Returns a
ValidationResultcontaining lists of errors and warnings. Validates per-suffix configuration blocks and global keys such asloop_over. BidsConfigAnalyzer-
Inspects the loaded config map and returns a boolean analysis map (
hasNamedSets,hasSequentialSets,hasMixedSets,hasPlainSets).BidsHandleruses this map to decide whichBaseSetHandlersubclasses to instantiate. Also extracts theloop_overentity list.
See Configuration for the YAML schema.
nfneuro.plugin.grouping — Set Handlers
BaseSetHandler-
Abstract base providing the
process(datasetRoot, bidsFiles, config, loopOverEntities, suffixMapping)template and the staticgetSetType()helper. PlainSetHandler-
Handles
plain_setentries — one file per subject/session/run group per suffix. NamedSetHandler-
Handles
named_setentries — multiple acquisition-direction variants collected under a config key (e.g.,dwi_apwithapandpasub-keys). SequentialSetHandler-
Handles
sequential_setentries — variable-length sequences such as multi-echo acquisitions, emitted as ordered lists. MixedSetHandler-
Handles
mixed_setentries — heterogeneous datasets where the same suffix maps to multiple config keys viasuffix_maps_to.
Multiple handler types can be active simultaneously for a single config file.
See BIDS Parsing for set-type semantics.
nfneuro.plugin.model — Domain Objects
BidsDataset-
Root container for a parsed dataset. Loads
dataset_description.jsonandparticipants.tsvon construction. BidsFile-
Represents one file entry from the libBIDS.sh TSV. Carries the path, suffix, associated extensions (
.nii.gz,.json,.bval,.bvec, etc.), and a list ofBidsEntityobjects. BidsEntity-
A key-value pair (e.g.,
subject=sub-01). Holds the canonical long-form entity name and aSHORT_ENTITY_MAPPINGthat maps long names to BIDS prefix abbreviations. BidsChannelData-
The transient accumulator used by the set handlers before items are emitted. Stores a
Map<String, Object> data(keyed by suffix), a list of raw file paths, and thebidsParentDir.toChannelTuple()converts the accumulator to the[groupingKey, enrichedData]tuple consumed byBidsHandler.
nfneuro.plugin.util — Cross-Cutting Utilities
BidsLogger-
Thin Slf4j wrapper that prefixes every message with a bracketed context tag (e.g.,
[nf-bids-handler]). SuffixMapper-
Builds a
Map<setType, Map<configKey, actualSuffix>>fromsuffix_maps_toentries. Used by the set handlers to resolve heterogeneous suffix configurations. BidsEntityUtils-
Static helpers for filtering
BidsFilelists by entity values and checking entity matches. BidsErrorHandler-
Provides
tryWithContext()for exception wrapping andcreateDetailedError()for multi-bullet diagnostic messages. BidsCsvParser-
Parses the TSV produced by
libBIDSsh_parse_bids_to_table. The expected column order isderivatives,datatype,subject,template,session,cohort,sample,task,tracksys,acquisition,nucleus,volume,ceagent,tracer,stain,reconstruction,direction,run,modality,echo,flip,inversion,mtransfer,part,processing,hemisphere,space,split,recording,chunk,atlas,segmentation,scale,resolution,density,label,description,suffix,extension,path(tab-separated).
Dependency Direction
The dependency graph flows in one direction: higher-level packages depend on lower-level ones, never the reverse.
nfneuro.plugin
└── nfneuro.plugin.channel
├── nfneuro.plugin.channel.operations
│ └── nfneuro.plugin.channel.operations.keys
├── nfneuro.plugin.parser
│ └── (uses nfneuro.plugin.util)
├── nfneuro.plugin.config
│ └── (uses nfneuro.plugin.util)
├── nfneuro.plugin.grouping
│ └── (uses nfneuro.plugin.model, nfneuro.plugin.util)
└── nfneuro.plugin.model
nfneuro.plugin.util is the only package imported by all others; it has no internal dependencies.
Related Pages
-
Runtime Entry Path — step-by-step call trace
-
The libBIDS.sh Dependency — external bash library
-
Dependency Matrix — all version-pinned dependencies
-
Plugin Bootstrap — pf4j lifecycle details
-
Configuration — YAML schema reference