Пример #1
0
        public static TaskEventCollection?Collect(BrainVisionPackage filesContent)
        {
            IHeaderFileContentVer1 headerContent = filesContent.HeaderFileContent;
            IMarkerFileContentVer1?markerContent = filesContent.MarkerFileContent;

            List <MarkerInfo>?markers = markerContent?.GetMarkers();

            if (markers == null)
            {
                return(null);
            }

            double samplingFrequency = Common.GetSamplingFrequencyFromSamplingInterval(headerContent.SamplingInterval !.Value);

            TaskEventCollection taskEvents = new TaskEventCollection();

            foreach (MarkerInfo marker in markers)
            {
                TaskEvent taskEvent = new TaskEvent(
                    //REQUIRED
                    onset: marker.Position / samplingFrequency,
                    duration: marker.Length / samplingFrequency)
                {
                    //OPTIONAL
                    Sample    = marker.Position + 1, // I suppose bids uses 1-based sample position. This info is not present in the official bids documentations
                    TrialType = marker.Type,
                    Value     = !string.IsNullOrEmpty(marker.Description) ? marker.Description : Defs.NotAvailable,
                };

                taskEvents.Add(taskEvent);
            }

            return(taskEvents);
        }
Пример #2
0
        public static void Save(StreamWriter writer, IMarkerFileContentVer1 content)
        {
            List <MarkerInfo>?markers = content.GetMarkers();

            if (markers != null)
            {
                writer.WriteLine();
                writer.WriteLine(IniFormat.FormatSectionName(Definitions.GetSectionName(Definitions.Section.MarkerInfos) !));
                FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.BelowMarkerInfosSection);

                for (int mk = 0; mk < markers.Count; ++mk)
                {
                    MarkerInfo marker = markers[mk];

                    string keyName  = Invariant($"{Definitions.KeyMkPlaceholder}{mk + 1}");
                    string keyValue = ConvertMarkerInfoToString(marker);

                    string line = IniFormat.FormatKeyValueLine(keyName, keyValue);
                    writer.WriteLine(line);
                }
            }
        }