43 return QStringLiteral(
"fiff_raw");
45 return QStringLiteral(
"forward");
47 return QStringLiteral(
"inverse");
49 return QStringLiteral(
"covariance");
51 return QStringLiteral(
"source_estimate");
53 return QStringLiteral(
"epochs");
55 return QStringLiteral(
"evoked");
57 return QStringLiteral(
"matrix");
59 return QStringLiteral(
"volume");
61 return QStringLiteral(
"surface");
63 return QStringLiteral(
"bem");
65 return QStringLiteral(
"annotation");
67 return QStringLiteral(
"label");
69 return QStringLiteral(
"real_time_stream");
71 return QStringLiteral(
"custom");
73 return QStringLiteral(
"custom");
78static MnaDataKind dataKindFromString(
const QString& str)
80 if (str == QLatin1String(
"fiff_raw"))
82 if (str == QLatin1String(
"forward"))
84 if (str == QLatin1String(
"inverse"))
86 if (str == QLatin1String(
"covariance"))
88 if (str == QLatin1String(
"source_estimate"))
90 if (str == QLatin1String(
"epochs"))
92 if (str == QLatin1String(
"evoked"))
94 if (str == QLatin1String(
"matrix"))
96 if (str == QLatin1String(
"volume"))
98 if (str == QLatin1String(
"surface"))
100 if (str == QLatin1String(
"bem"))
102 if (str == QLatin1String(
"annotation"))
104 if (str == QLatin1String(
"label"))
106 if (str == QLatin1String(
"real_time_stream"))
117 return QStringLiteral(
"input");
119 return QStringLiteral(
"output");
121 return QStringLiteral(
"input");
126static MnaPortDir portDirFromString(
const QString& str)
128 if (str == QLatin1String(
"output"))
139 QJsonObject json =
extras;
140 json[QLatin1String(
"name")] =
name;
141 json[QLatin1String(
"data_kind")] = dataKindToString(
dataKind);
142 json[QLatin1String(
"direction")] = portDirToString(
direction);
168 port.
name = json[QLatin1String(
"name")].toString();
169 port.
dataKind = dataKindFromString(json[QLatin1String(
"data_kind")].toString());
170 port.
direction = portDirFromString(json[QLatin1String(
"direction")].toString());
171 port.
sourceNodeId = json[QLatin1String(
"source_node")].toString();
172 port.
sourcePortName = json[QLatin1String(
"source_port")].toString();
173 port.
streamProtocol = json[QLatin1String(
"stream_protocol")].toString();
174 port.
streamEndpoint = json[QLatin1String(
"stream_endpoint")].toString();
175 port.
streamBufferMs = json[QLatin1String(
"stream_buffer_ms")].toInt(0);
177 port.
cachedResultHash = json[QLatin1String(
"cached_result_hash")].toString();
179 static const QSet<QString> knownKeys = {
180 QStringLiteral(
"name"), QStringLiteral(
"data_kind"),
181 QStringLiteral(
"direction"), QStringLiteral(
"source_node"),
182 QStringLiteral(
"source_port"), QStringLiteral(
"stream_protocol"),
183 QStringLiteral(
"stream_endpoint"), QStringLiteral(
"stream_buffer_ms"),
184 QStringLiteral(
"cached_result"), QStringLiteral(
"cached_result_hash")};
185 for (
auto it = json.constBegin(); it != json.constEnd(); ++it) {
186 if (!knownKeys.contains(it.key()))
187 port.
extras.insert(it.key(), it.value());
197 QCborMap cbor = QCborMap::fromJsonObject(
extras);
198 cbor[QLatin1String(
"name")] =
name;
199 cbor[QLatin1String(
"data_kind")] = dataKindToString(
dataKind);
200 cbor[QLatin1String(
"direction")] = portDirToString(
direction);
224 port.
name = cbor[QLatin1String(
"name")].toString();
225 port.
dataKind = dataKindFromString(cbor[QLatin1String(
"data_kind")].toString());
226 port.
direction = portDirFromString(cbor[QLatin1String(
"direction")].toString());
227 port.
sourceNodeId = cbor[QLatin1String(
"source_node")].toString();
228 port.
sourcePortName = cbor[QLatin1String(
"source_port")].toString();
229 port.
streamProtocol = cbor[QLatin1String(
"stream_protocol")].toString();
230 port.
streamEndpoint = cbor[QLatin1String(
"stream_endpoint")].toString();
231 port.
streamBufferMs = cbor[QLatin1String(
"stream_buffer_ms")].toInteger();
233 port.
cachedResultHash = cbor[QLatin1String(
"cached_result_hash")].toString();
235 static const QSet<QString> knownKeys = {
236 QStringLiteral(
"name"), QStringLiteral(
"data_kind"),
237 QStringLiteral(
"direction"), QStringLiteral(
"source_node"),
238 QStringLiteral(
"source_port"), QStringLiteral(
"stream_protocol"),
239 QStringLiteral(
"stream_endpoint"), QStringLiteral(
"stream_buffer_ms"),
240 QStringLiteral(
"cached_result"), QStringLiteral(
"cached_result_hash")};
241 QJsonObject cborJson = cbor.toJsonObject();
242 for (
auto it = cborJson.constBegin(); it != cborJson.constEnd(); ++it) {
243 if (!knownKeys.contains(it.key()))
244 port.
extras.insert(it.key(), it.value());
Typed input or output slot on a graph node — carries an MnaDataKind, an upstream link,...
MNE Analysis Container Format (mna/mnx).
@ FiffRaw
Raw MEG/EEG data (FIFF format).
@ Annotation
FreeSurfer annotation / parcellation.
@ Forward
Forward solution.
@ SourceEstimate
Source-level time series.
@ Custom
User-defined data kind.
@ Inverse
Inverse operator.
@ Surface
Surface mesh (FreeSurfer).
@ Covariance
Noise or data covariance matrix.
@ RealTimeStream
Live data channel (MNE Scan / LSL / FIFF-RT).
@ Evoked
Averaged evoked response.
@ Matrix
Generic Eigen matrix (for intermediate results).
Named, typed port on an MNA graph node with upstream link and optional real-time stream binding.
QString cachedResultHash
SHA-256 for invalidation.
QString name
Port name (unique within a node).
QJsonObject toJson() const
QString sourcePortName
Which output port on that node?
MnaDataKind dataKind
Data kind flowing through this port.
MnaPortDir direction
Input or Output.
QString cachedResultPath
Relative path to cached result.
int streamBufferMs
Ring-buffer length in ms (0 = unbounded).
QString streamEndpoint
Protocol-specific address (e.g. "localhost:4218" for fiff-rt).
QJsonObject extras
Unknown keys preserved for lossless round-trip.
static MnaPort fromJson(const QJsonObject &json)
QString sourceNodeId
Which node produces this input? (empty → graph-level input).
static MnaPort fromCbor(const QCborMap &cbor)
QString streamProtocol
"fiff-rt", "lsl", "ftbuffer", "shm", "" = internal signal/slot