Example #1
0
  private File getTagFileName(NewStagerTagCollectionType key) {
    String path = this.stagerData.getProjectPath();
    String bookPath = this.stagerData.getParameters().bookFilePath;
    String bookName = Util.getFileNameWithoutExtension(new File(bookPath));

    NewStagerFASPThreshold deltaThreshold =
        this.stagerData.getParameters().thresholds.deltaThreshold;

    String type = "";
    switch (key) {
      case HYPNO_DELTA:
        type = "delta";
        break;
      case HYPNO_ALPHA:
        type = "alpha";
        break;
      case HYPNO_SPINDLE:
        type = "spindles";
        break;
      case SLEEP_PAGES:
        type = String.format(Locale.ROOT, "PrimHypnos_a%3.2f", deltaThreshold.amplitude.getMin());
        break;
      case CONSOLIDATED_SLEEP_PAGES:
        type = String.format(Locale.ROOT, "hypnos_a%3.2f", deltaThreshold.amplitude.getMin());
        break;
      default:
        return null;
    }

    String name = String.format("%s_%s.tag", bookName, type);
    return new File(path, name);
  }
  public static void main(String[] args) {
    LegacyTagImporter importer = new LegacyTagImporter();
    StyledTagSet tags;

    File sourceFile = new File(path);
    try {
      tags = importer.importLegacyTags(sourceFile, samplingFrequency);
    } catch (SignalMLException e) {
      logger.error("", e);
      return;
    }

    File outputFile =
        new File(sourceFile.getParent(), Util.getFileNameWithoutExtension(sourceFile) + "conv.xml");

    TagDocument d;
    try {
      d = new TagDocument(tags);
    } catch (SignalMLException e) {
      logger.error("", e);
      return;
    }

    d.setBackingFile(outputFile);
    try {
      d.saveDocument();
      d.closeDocument();
    } catch (SignalMLException e) {
      logger.error("", e);
      return;
    } catch (IOException e) {
      logger.error("", e);
      return;
    }
  }