Пример #1
0
 private void GenerateSubjectSessionAndTaskIfNotProvided(CustomizationInfo info, string brainVisionHeaderFilePath,
                                                         out string subjectName, out string?sessionName, out string taskName)
 {
     subjectName = info.SubjectName ?? GetNextAvailableSubjectName(_destinationFolderPath);
     sessionName = info.SessionName; // it is allowed session to be null
     taskName    = info.TaskName ?? RemoveBidsSpecialCharacters(Path.GetFileNameWithoutExtension(brainVisionHeaderFilePath));
 }
Пример #2
0
        private void Convert(BrainVisionPackage bvPackage, IBidsPackage bidsPackage, CustomizationInfo info)
        {
            Warnings = Array.Empty <string>();
            PackageConverter converter = new PackageConverter(bvPackage, bidsPackage, info);

            converter.CopyBrainVisionFilesToBidsEegModalityFolder();
            bvPackage.UpdateMissingKeysWithDefaultValues();
            converter.ConvertBrainVisionFilesToBidsFormatFiles();
            Warnings = converter.Warnings;
        }
Пример #3
0
        /// <exception cref="ArgumentException">Thrown when <paramref name="brainVisionHeaderFilePath"/>consists only of white characters.</exception>
        /// <exception cref="InvalidOperationException">Thrown when vision file fails to load.</exception>
        /// <exception cref="NotSupportedException">Thrown when units are not recognized.</exception>
        public void Convert(string brainVisionHeaderFilePath, CustomizationInfo info)
        {
            if (string.IsNullOrWhiteSpace(brainVisionHeaderFilePath))
            {
                throw new ArgumentException(Resources.ArgumentEmptyOrWhiteCharactersExceptionMessage, nameof(brainVisionHeaderFilePath));
            }

            GenerateSubjectSessionAndTaskIfNotProvided(info, brainVisionHeaderFilePath, out string subjectName, out string?sessionName, out string taskName);

            IBidsPackage       bidsPackage = CreateBidsPackage(subjectName, sessionName, taskName);
            BrainVisionPackage bvPackage   = CreateBvPackage(brainVisionHeaderFilePath);

            Convert(bvPackage, bidsPackage, info);
        }
Пример #4
0
        private static bool Convert(string brainVisionHeaderFilePath, string destinationFolderPath, CustomizationInfo info)
        {
            try
            {
                BrainVisionToBidsConverter converter = new BrainVisionToBidsConverter(destinationFolderPath);
                converter.Convert(brainVisionHeaderFilePath, info);
                return(true);
            }
#pragma warning disable CA1031  // Do not catch general exception types
            catch (Exception e) // all possible exceptions must be caught, program may not crash
            {
                Console.WriteLine($"{Resources.ConsoleOutputConversionFailed} {e.Message}");
                return(false);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }