예제 #1
0
        public static EegChannelCollection?Collect(BrainVisionPackage filesContent)
        {
            IHeaderFileContentVer1 headerContent = filesContent.HeaderFileContent;
            List <ChannelInfo>?    inputChannels = headerContent.GetChannelInfos();

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

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

            EegChannelCollection eegChannels = new EegChannelCollection();

            foreach (ChannelInfo inputChannel in inputChannels)
            {
                PrefixedUnit?channelUnits = Common.ConvertTextToPrefixedUnit(inputChannel.Unit);
                if (channelUnits == null)
                {
                    throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, Resources.UrecognizedUnitExceptionMessage, inputChannel.Unit, inputChannel.Name));
                }

                EegChannel eegChannel = new EegChannel(
                    //REQUIRED
                    name: inputChannel.Name,
                    type: ChannelType.EEG,
                    units: channelUnits.Value)
                {
                    //OPTIONAL
                    SamplingFrequency = samplingFrequency,
                    //Reference = null,
                    //LowCutoff = null,
                    //HighCutoff = null,
                    //Notch = null,
                };

                eegChannels.Add(eegChannel);
            }

            return(eegChannels);
        }
예제 #2
0
        public static void Save(StreamWriter writer, IHeaderFileContentVer1 content)
        {
            List <ChannelInfo>?channelInfos = content.GetChannelInfos();

            if (channelInfos != null)
            {
                writer.WriteLine();
                writer.WriteLine(IniFormat.FormatSectionName(Definitions.GetSectionName(Definitions.Section.ChannelInfos) !));
                FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.BelowChannelInfosSection);

                for (int ch = 0; ch < channelInfos.Count; ++ch)
                {
                    ChannelInfo channelInfo = channelInfos[ch];

                    string keyName  = Invariant($"{Definitions.KeyChPlaceholder}{ch + 1}");
                    string keyValue = ConvertChannelInfoToString(channelInfo);

                    string line = IniFormat.FormatKeyValueLine(keyName, keyValue);
                    writer.WriteLine(line);
                }
            }
        }
예제 #3
0
        public static EegElectrodeCollection?Collect(BrainVisionPackage filesContent)
        {
            IHeaderFileContentVer1 headerContent    = filesContent.HeaderFileContent;
            List <Coordinates>?    inputCoordinates = headerContent.GetChannelCoordinates();

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

            List <ChannelInfo>?inputChannels = headerContent.GetChannelInfos();
            int inputChannelsCount           = inputChannels == null ? 0 : inputChannels.Count;

            EegElectrodeCollection eegElectrodes = new EegElectrodeCollection();

            for (int channelNumber = 0; channelNumber < inputCoordinates.Count; ++channelNumber)
            {
                Coordinates coordinates = inputCoordinates[channelNumber];

                (double cartesianX, double cartesianY, double cartesianZ) = SphericalToCartesian(coordinates);

                EegElectrode eegElectrode = new EegElectrode(
                    //REQUIRED
                    name: channelNumber < inputChannelsCount ? inputChannels ![channelNumber].Name : string.Empty,
예제 #4
0
        public static EegSidecar Collect(BrainVisionPackage filesContent, CustomizationInfo info, string actualTaskName)
        {
            IHeaderFileContentVer1 headerContent = filesContent.HeaderFileContent;
            List <ChannelInfo>?    channelInfos  = headerContent.GetChannelInfos();

            EegSidecar sidecar = new EegSidecar(
                //REQUIRED Generic
                actualTaskName,

                //REQUIRED EEG
                info.EEGReference,
                Common.GetSamplingFrequencyFromSamplingInterval(headerContent.SamplingInterval !.Value), // SamplingInterval is in µs
                info.PowerLineFrequency,
                Defs.NotAvailable)
            {
                #region Generic
                //RECOMMENDED
                Manufacturer = info.Manufacturer,
                #endregion

                #region EEG
                //RECOMMENDED
                EEGChannelCount     = channelInfos == null ? 0 : channelInfos.Count,
                ECGChannelCount     = 0,
                EMGChannelCount     = 0,
                EOGChannelCount     = 0,
                MiscChannelCount    = 0,
                TriggerChannelCount = 0,
                //RecordingDuration = 0,
                RecordingType = headerContent.Averaged !.Value ? EegSidecar.Recordingtype.epoched : EegSidecar.Recordingtype.continuous,
                EpochLength   = headerContent.Averaged.Value ? ((headerContent.SegmentDataPoints !.Value * headerContent.SamplingInterval.Value) / 1000000.0) as double?: null,
                #endregion
            };

            return(sidecar);
        }