Skip to content

Commit

Permalink
Further work on ECAT
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Apr 26, 2017
1 parent 3aa614e commit dfce355
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 41 deletions.
2 changes: 1 addition & 1 deletion console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ size_t nii_SliceBytes(struct nifti_1_header hdr) {
if (hdr.dim[i] > 1)
imgsz = imgsz * hdr.dim[i];
return imgsz;
} //nii_ImgBytes()
} //nii_SliceBytes()

size_t nii_ImgBytes(struct nifti_1_header hdr) {
size_t imgsz = hdr.bitpix/8;
Expand Down
1 change: 1 addition & 0 deletions console/nii_dicom.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static const int kCompress50 = 3; //obsolete JPEG lossy
unsigned char * nii_planar2rgb(unsigned char* bImg, struct nifti_1_header *hdr, int isPlanar);
int isDICOMfile(const char * fname); //0=not DICOM, 1=DICOM, 2=NOTSURE(not part 10 compliant)
int headerDcm2Nii2(struct TDICOMdata d, struct TDICOMdata d2, struct nifti_1_header *h);
int headerDcm2Nii(struct TDICOMdata d, struct nifti_1_header *h) ;
//unsigned char * nii_loadImgX(char* imgname, struct nifti_1_header *hdr, struct TDICOMdata dcm, bool iVaries);
unsigned char * nii_loadImgXL(char* imgname, struct nifti_1_header *hdr, struct TDICOMdata dcm, bool iVaries, int compressFlag, int isVerbose);
//int foo (float vx);
Expand Down
12 changes: 8 additions & 4 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void nii_SaveBIDS(char pathoutname[], struct TDICOMdata d, struct TDCMopts opts,
//printf("-%02d-%02dT%02d:%02d:%02.6f\",\n", amonth, aday, ahour, amin, asec);
if (count) { // ISO 8601 specifies a sign must exist for distant years.
//report time of the day only format, https://www.cs.tut.fi/~jkorpela/iso8601.html
fprintf(fp, "\t\"AcquisitionTime\": %02d:%02d:%02.6f\",\n",ahour, amin, asec);
fprintf(fp, "\t\"AcquisitionTime\": \"%02d:%02d:%02.6f\",\n",ahour, amin, asec);
//report date and time together
if (!opts.isAnonymizeBIDS) {
fprintf(fp, "\t\"AcquisitionDateTime\": ");
Expand Down Expand Up @@ -722,7 +722,7 @@ bool intensityScaleVaries(int nConvert, struct TDCMsort dcmSort[],struct TDICOMd
sliceOffsetR += sliceBytes8;
} //for each slice
return bImg;
} //nii_ImgBytes()*/
} */

bool niiExists(const char*pathoutname) {
char niiname[2048] = {""};
Expand Down Expand Up @@ -1092,6 +1092,10 @@ void nii_saveAttributes (struct TDICOMdata &data, struct nifti_1_header &header,
int nii_saveNII(char * niiFilename, struct nifti_1_header hdr, unsigned char* im, struct TDCMopts opts) {
hdr.vox_offset = 352;
size_t imgsz = nii_ImgBytes(hdr);
if (imgsz < 1) {
printMessage("Error: Image size is zero bytes %s\n", niiFilename);
return EXIT_FAILURE;
}
#ifndef myDisableZLib
if ((opts.isGz) && (strlen(opts.pigzname) < 1) && ((imgsz+hdr.vox_offset) < 2147483647) ) { //use internal compressor
writeNiiGz (niiFilename, hdr, im, imgsz, opts.gzLevel);
Expand Down Expand Up @@ -2111,8 +2115,8 @@ int nii_loadDir(struct TDCMopts* opts) {
}*/
getFileName(opts->indirParent, opts->indir);
if (isFile && ( (isExt(indir, ".v"))) ) {
//open_foreign(opts->indir);
return open_foreign (indir);
//return open_foreign (indir);
return open_foreign (indir, *opts);

}
if (isFile && ( (isExt(indir, ".par")) || (isExt(indir, ".rec"))) ) {
Expand Down

0 comments on commit dfce355

Please sign in to comment.