Skip to content

Instantly share code, notes, and snippets.

@ofgulban
Last active December 22, 2016 18:38
Show Gist options
  • Save ofgulban/7421e51198a1e4a47d2815d52e71381a to your computer and use it in GitHub Desktop.
Save ofgulban/7421e51198a1e4a47d2815d52e71381a to your computer and use it in GitHub Desktop.
Brainvoyager scripting example for creating fmr files.
// Batch script for cretaing FMR files from renamed dicom files (.dcm).
//
// You need to create the subfolders in the main data path beforehand.
// For instance: /path/to/your/subject/RUN_1
// /path/to/your/subject/RUN_2
// ...
//
// For more information, check the scripting guide:
// http://support.brainvoyager.com/automation-aamp-development/46-writing-scripts/133-scripting-reference-guide.html
var bvqx = BrainVoyagerQX;
bvqx.PrintToLog("---");
//----------------------------------------------------------------
// Enter the following values:
var MainDataPath = "/path/to/your/subject/";
var RunPrefix = "RUN_";
// Enter the first dicom file paths per run.
var InDicomList = ["/path/to/your/dicoms/data-0001-0001-00001.dcm",
"/path/to/your/dicoms/data-0002-0001-00001.dcm",
"/path/to/your/dicoms/data-0003-0001-00001.dcm",
"/path/to/your/dicoms/data-0004-0001-00001.dcm"];
// Enter the run names.
var RunNameList = ["S01_RUN_01",
"S01_RUN_02",
"S01_RUN_03",
"S01_RUN_04"];
var NrVolPerRunList = [150, 150, 150, 150];
//----------------------------------------------------------------
var NrOfRuns = InDicomList.length;
for(count = 1; count <= NrOfRuns; count++){
var RunPath = MainDataPath + RunPrefix + String(count) + "/";
var RunName = RunNameList[count-1];
var InDicomPath = InDicomList[count-1];
// Create FMR Project
var docFMR = bvqx.CreateProjectMosaicFMR("DICOM", InDicomPath,
NrVolPerRunList[count-1], //nr of volumes
0, //nr of volumes to skip
false, //create AMR
46, //nr of slices
RunName, //STC prefix
false, //swap bytes
1316, 1316, //dimension of images in volume x, y
2, //nr of bytes per pixel, usually 2
RunPath, //saving directory
1, //number of volumes per file
188, 188 //dimension of image x, y
);
// Give prefixed names
docFMR.SaveAs(RunName);
bvqx.PrintToLog(RunName + " is done.");
};
bvqx.PrintToLog("Finished.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment