private void btnValidateCsv_Click(object sender, EventArgs e)
    {
        var  mapping = new CsvToDicomTagMapping();
        bool built   = mapping.BuildMap(State, out string log);

        MessageBox.Show(log, $"Validation { (built ? "Success" : "Failure" )}", MessageBoxButtons.OK, built ? MessageBoxIcon.Information: MessageBoxIcon.Error);
    }
Ejemplo n.º 2
0
        public FilePathMatcher(CsvToDicomTagMapping map, DicomRepopulatorOptions options) : base(map, options)
        {
            if (map.FilenameColumn == null)
            {
                throw new ArgumentException("Map did not contain file name column");
            }

            Reader = new(map.CsvFile.OpenText(), new CsvConfiguration(System.Globalization.CultureInfo.CurrentCulture) with
            {
                TrimOptions = TrimOptions.Trim
            });
        public RepopulatorMatcher(CsvToDicomTagMapping map, DicomRepopulatorOptions options)
        {
            Options = options;
            Map     = map;

            if (!Map.IsBuilt)
            {
                throw new ArgumentException("Map has not been built yet");
            }

            if (string.IsNullOrWhiteSpace(options.InputFolder))
            {
                throw new ArgumentException("InputFolder has not been set");
            }
        }
        public IRepopulatorMatcher Create(CsvToDicomTagMapping map, DicomRepopulatorOptions options)
        {
            //We have a column that contains the exact location on disk of the image.  This is the best because it lets us stream the CSV
            if (map.FilenameColumn != null)
            {
                return(new FilePathMatcher(map, options));
            }

            //We have no file path column so must do matching based on 'key'.  This will require loading entire CSV into memory which may break
            //for very large datasets
            if (map.TagColumns.Any(c =>
                                   c.TagsToPopulate.Contains(DicomTag.SOPInstanceUID) ||
                                   c.TagsToPopulate.Contains(DicomTag.SeriesInstanceUID) ||
                                   c.TagsToPopulate.Contains(DicomTag.StudyInstanceUID)))
            {
                return(new TagMatcher(map, options));
            }

            return(null);
        }