@@ -1110,7 +1110,7 @@ MRIS *mrisReadGIFTIdanum(const char *fname, MRIS *mris, int daNum, MRI *outmri,
1110
1110
gifti_free_image (image);
1111
1111
1112
1112
return mris;
1113
- }
1113
+ } // end of mrisReadGIFTIdanum()
1114
1114
1115
1115
1116
1116
/* -----------------------------------------------------------
@@ -1275,7 +1275,7 @@ MRI *MRISreadGiftiAsMRI(const char *fname, int read_volume)
1275
1275
/* And we're done. */
1276
1276
gifti_free_image (image);
1277
1277
return (mri);
1278
- }
1278
+ } // end of MRISreadGiftiAsMRI()
1279
1279
1280
1280
/*
1281
1281
* insert username and current date into meta data
@@ -1359,7 +1359,7 @@ int MRISwriteGIFTI(MRIS *mris, int intent_code, const char *out_fname, const cha
1359
1359
gifti_free_image (image);
1360
1360
1361
1361
return ERROR_NONE;
1362
- }
1362
+ } // end of MRISwriteGIFTI()
1363
1363
1364
1364
/* -----------------------------------------------------------
1365
1365
Parameters: MRI structure (surface-encoded volume),
@@ -1471,7 +1471,7 @@ int mriWriteGifti(MRI *mri, const char *out_fname)
1471
1471
gifti_free_image (image);
1472
1472
1473
1473
return ERROR_NONE;
1474
- }
1474
+ } // end of mriWriteGifti()
1475
1475
1476
1476
1477
1477
@@ -1524,7 +1524,7 @@ int MRISwriteGIFTIIntent(MRIS *mris, int intent_code, gifti_image *image, const
1524
1524
} // end of if NIFTI_INTENT_<stats>
1525
1525
1526
1526
return NO_ERROR;
1527
- } // end of MRISwriteGIFTIIntent()
1527
+ } // end of MRISwriteGIFTIIntent(MRIS *mris, ... )
1528
1528
1529
1529
1530
1530
/*
@@ -1613,7 +1613,7 @@ int MRISwriteGIFTIShape(MRIS *mris, gifti_image *image, int intent_code, const c
1613
1613
}
1614
1614
1615
1615
return NO_ERROR;
1616
- } // end of MRISwriteGIFTIShape()
1616
+ } // end of MRISwriteGIFTIShape(MRIS *mris, ... )
1617
1617
1618
1618
1619
1619
/*
@@ -1676,7 +1676,7 @@ int MRISwriteGIFTIStats(MRIS *mris, gifti_image *image, int intent_code)
1676
1676
}
1677
1677
1678
1678
return NO_ERROR;
1679
- } // end of MRISwriteGIFTIStats()
1679
+ } // end of MRISwriteGIFTIStats(MRIS *mris, ... )
1680
1680
1681
1681
1682
1682
/*
@@ -2304,7 +2304,7 @@ int MRISwriteGIFTIIntent(MRIS *mris, const MRI *mri, int stframe, int endframe,
2304
2304
} // end of if NIFTI_INTENT_<stats>
2305
2305
2306
2306
return NO_ERROR;
2307
- }
2307
+ } // end of MRISwriteGIFTIIntent(MRIS *mris, const MRI *mri, ...)
2308
2308
2309
2309
2310
2310
/*
@@ -2424,7 +2424,7 @@ int MRISwriteGIFTIShape(MRIS *mris, const MRI *mri, int stframe, int endframe, g
2424
2424
#endif
2425
2425
2426
2426
return NO_ERROR;
2427
- } // end of MRISwriteGIFTIShape()
2427
+ } // end of MRISwriteGIFTIShape(MRIS *mris, const MRI *mri, ... )
2428
2428
2429
2429
2430
2430
/*
@@ -2513,4 +2513,61 @@ int MRISwriteGIFTIStats(MRIS *mris, const MRI *mri, int stframe, int endframe, g
2513
2513
#endif
2514
2514
2515
2515
return NO_ERROR;
2516
- } // end of MRISwriteGIFTIStats()
2516
+ } // end of MRISwriteGIFTIStats(MRIS *mris, const MRI *mri, ...)
2517
+
2518
+
2519
+ int getShapeStatIntentCount (const char *fgifti)
2520
+ {
2521
+ /*
2522
+ * attempt to read the file
2523
+ */
2524
+ gifti_image *image = gifti_read_image (fgifti, 1 );
2525
+ if (NULL == image) {
2526
+ fprintf (stderr, " getShapeStatIntentCount(): gifti_read_image() returned NULL\n " );
2527
+ return 0 ;
2528
+ }
2529
+
2530
+ // make sure version is recoded before validation
2531
+ if (!strcmp (image->version , " 1" )) {
2532
+ free (image->version );
2533
+ image->version = strcpyalloc (GIFTI_XML_VERSION);
2534
+ }
2535
+
2536
+ /*
2537
+ * check for compliance
2538
+ */
2539
+ int valid = gifti_valid_gifti_image (image, 1 );
2540
+ if (valid == 0 ) {
2541
+ fprintf (stderr, " getShapeStatIntentCount(): GIFTI file %s is invalid!\n " , fgifti);
2542
+ gifti_free_image (image);
2543
+ return 0 ;
2544
+ }
2545
+
2546
+ /*
2547
+ * Now parse the DataArrays, count NIFTI_INTENT_SHAPE and NIFTI_INTENT_<stat>
2548
+ */
2549
+ int count = 0 ;
2550
+ int endDAnum = image->numDA ;
2551
+ for (int numDA = 0 ; numDA < endDAnum; numDA++) {
2552
+ giiDataArray *darray = image->darray [numDA];
2553
+
2554
+ // skip these intents
2555
+ if ((darray->intent == NIFTI_INTENT_POINTSET) ||
2556
+ (darray->intent == NIFTI_INTENT_TRIANGLE) ||
2557
+ (darray->intent == NIFTI_INTENT_LABEL) ||
2558
+ (darray->intent == NIFTI_INTENT_GENMATRIX) ||
2559
+ (darray->intent == NIFTI_INTENT_VECTOR) ||
2560
+ (darray->intent == NIFTI_INTENT_RGB_VECTOR) ||
2561
+ (darray->intent == NIFTI_INTENT_RGBA_VECTOR))
2562
+ continue ;
2563
+
2564
+ count++;
2565
+ }
2566
+
2567
+ /*
2568
+ * And we're done.
2569
+ */
2570
+ gifti_free_image (image);
2571
+
2572
+ return count;
2573
+ } // end of getShapeStatIntentCount()
0 commit comments