-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from neurolabusc/batch_processing
Batch processing
- Loading branch information
Showing
6 changed files
with
248 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// main.m dcm2niix | ||
// by Chris Rorden on 3/22/14, released under Gnu General Public License, Version 2. | ||
// Copyright (c) 2014 Chris Rorden. All rights reserved. | ||
|
||
|
||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
#include <time.h> // clock_t, clock, CLOCKS_PER_SEC | ||
#include <stdio.h> | ||
#include <cmath> | ||
#include <string> | ||
#include <iostream> | ||
|
||
#include "nii_dicom_batch.h" | ||
|
||
#include <fstream> | ||
#include <yaml-cpp/yaml.h> | ||
|
||
const char* removePath(const char* path) { // "/usr/path/filename.exe" -> "filename.exe" | ||
const char* pDelimeter = strrchr (path, '\\'); | ||
if (pDelimeter) | ||
path = pDelimeter+1; | ||
pDelimeter = strrchr (path, '/'); | ||
if (pDelimeter) | ||
path = pDelimeter+1; | ||
return path; | ||
} //removePath() | ||
|
||
|
||
int rmainbatch(TDCMopts opts) | ||
{ | ||
printf("Chris Rorden's dcm2niiX version %s (%lu-bit)\n",kDCMvers, sizeof(size_t)*8); | ||
|
||
clock_t start = clock(); | ||
nii_loadDir(&opts); | ||
printf ("Conversion required %f seconds.\n",((float)(clock()-start))/CLOCKS_PER_SEC); | ||
return EXIT_SUCCESS; | ||
} | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
|
||
if (argc != 2) { | ||
std::cout << "Do not include additional inputs with a config file \n"; | ||
throw; | ||
} | ||
|
||
// Process it all via a yaml file | ||
std::string yaml_file = argv[1]; | ||
std::cout << "yaml_path: " << yaml_file << std::endl; | ||
YAML::Node config = YAML::LoadFile(yaml_file); | ||
|
||
struct TDCMopts opts; | ||
|
||
opts.isCreateBIDS = config["Options"]["isCreateBIDS"].as<bool>(); | ||
opts.isOnlySingleFile = config["Options"]["isOnlySingleFile"].as<bool>(); | ||
opts.isCreateText = false; | ||
opts.isVerbose = false; | ||
opts.isGz = config["Options"]["isGz"].as<bool>(); //force use of internal compression instead of pigz | ||
if (opts.isGz) { | ||
// TODO this is not the same as previous | ||
strcpy(opts.pigzname, ""); | ||
} | ||
|
||
for (auto i: config["Files"]) { | ||
|
||
std::string indir = i["in_dir"].as<std::string>(); | ||
strcpy(opts.indir, indir.c_str()); | ||
|
||
std::string outdir = i["out_dir"].as<std::string>(); | ||
strcpy(opts.outdir, outdir.c_str()); | ||
|
||
std::string filename = i["filename"].as<std::string>(); | ||
strcpy(opts.filename, filename.c_str()); | ||
|
||
rmainbatch(opts); | ||
|
||
} | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Options: | ||
isGz: false | ||
isFlipY: false | ||
isVerbose: false | ||
isCreateBIDS: false | ||
isOnlySingleFile: false | ||
|
||
Files: | ||
- | ||
in_dir: /path/to/first/folder | ||
out_dir: /path/to/output/folder | ||
filename: dcemri | ||
- | ||
in_dir: /path/to/second/folder | ||
out_dir: /path/to/output/folder | ||
filename: fa3 |