@@ -79,15 +79,17 @@ static const COLOR_TABLE miniColorTable =
79
79
80
80
int main (int argc, char *argv[]) ;
81
81
82
- static void __convertOverlayFile (MRIS *mris, const char *curv , char *out_fname);
82
+ static void __convertCurvatureFile (MRIS *mris, int noverlay, const char **foverlays , char *out_fname);
83
83
static void __writeLabelFile (MRIS *mris, const char *flabel, const char *label, const char *labelstats, char *out_fname);
84
- static void __writeAnnotFile (MRIS *mris, const char *fannot, int giftiDaNum, const char *parcstats, const char *fcurv, char *out_fname);
84
+ static void __writeAnnotFile (MRIS *mris, const char *fannot, int giftiDaNum, const char *parcstats, char *out_fname);
85
85
static void __writeFuncFile (const char *ffunc, char *out_fname);
86
86
static void __writeNormals (MRIS *mris, char *out_fname);
87
87
static void __writeMRISPatch (MRIS *mris, char *out_fname);
88
88
89
89
static int get_option (int argc, char *argv[]) ;
90
90
static void check_options (void );
91
+ static int isflag (char *flag);
92
+ static int nth_is_arg (int nargc, char **argv, int nth);
91
93
static void usage_exit (void ) ;
92
94
static void print_usage (void ) ;
93
95
static void print_help (void ) ;
@@ -112,6 +114,8 @@ static int w_file_dst_flag = 0 ;
112
114
static int w_file_src_flag = 0 ;
113
115
static int curv_file_flag = 0 ;
114
116
static char *curv_fname = NULL ;
117
+ static const char **arr_fcurv = NULL ;
118
+ static int nfcurv = 0 ;
115
119
static int func_file_flag = 0 ;
116
120
static char *func_fname = NULL ;
117
121
static int annot_file_flag = 0 ;
@@ -132,6 +136,7 @@ static int PrintXYZOnly = 0;
132
136
static MATRIX *XFM=NULL ;
133
137
static int write_vertex_neighbors = 0 ;
134
138
static int combinesurfs_flag = 0 ;
139
+ static int mergegifti_flag = 0 ;
135
140
static int userealras_flag = 0 ;
136
141
static int usesurfras_flag = 0 ;
137
142
static MRI *VolGeomMRI=NULL ;
@@ -407,9 +412,9 @@ main(int argc, char *argv[])
407
412
}
408
413
409
414
if (curv_file_flag)
410
- __convertOverlayFile (mris, curv_fname , out_fname);
415
+ __convertCurvatureFile (mris, nfcurv, arr_fcurv , out_fname);
411
416
else if (annot_file_flag)
412
- __writeAnnotFile (mris, annot_fname, gifti_da_num, parcstats_fname, curv_fname, out_fname);
417
+ __writeAnnotFile (mris, annot_fname, gifti_da_num, parcstats_fname, out_fname);
413
418
else if (label_file_flag)
414
419
__writeLabelFile (mris, label_fname, label_name, labelstats_fname, out_fname);
415
420
else if (func_file_flag)
@@ -488,11 +493,21 @@ main(int argc, char *argv[])
488
493
}
489
494
490
495
491
- static void __convertOverlayFile (MRIS *mris, const char *fcurv , char *out_fname)
496
+ static void __convertCurvatureFile (MRIS *mris, int noverlay, const char **foverlays , char *out_fname)
492
497
{
493
- MRISurfOverlay *fsOverlay = new MRISurfOverlay ();
494
- fsOverlay->read (fcurv, TRUE , mris);
495
- fsOverlay->write (out_fname, mris);
498
+ OverlayInfoStruct poverlayStruct[noverlay];
499
+ for (int n = 0 ; n < noverlay; n++)
500
+ {
501
+ poverlayStruct[n].__foverlay = foverlays[n];
502
+ poverlayStruct[n].__type = FS_MRISURFOVERLAY_SHAPE;
503
+ poverlayStruct[n].__format = MRISurfOverlay::getFileFormat (foverlays[n]);
504
+ poverlayStruct[n].__stframe = n; // assume one frame for each curvature
505
+ poverlayStruct[n].__numframe = 1 ;
506
+ }
507
+
508
+ MRISurfOverlay *fsOverlay = new MRISurfOverlay (mris, noverlay, &poverlayStruct[0 ]);
509
+ fsOverlay->read (TRUE , mris);
510
+ fsOverlay->write (out_fname, mris, (mergegifti_flag) ? true : false );
496
511
}
497
512
498
513
@@ -596,7 +611,7 @@ static void __writeLabelFile(MRIS *mris, const char *flabel, const char *labelna
596
611
}
597
612
598
613
599
- static void __writeAnnotFile (MRIS *mris, const char *fannot, int giftiDaNum, const char *parcstats, const char *fcurv, char *out_fname)
614
+ static void __writeAnnotFile (MRIS *mris, const char *fannot, int giftiDaNum, const char *parcstats, char *out_fname)
600
615
{
601
616
// first read the annotation/gifti label data...
602
617
int type = MRISfileNameType (fannot);
@@ -662,8 +677,7 @@ static void __writeAnnotFile(MRIS *mris, const char *fannot, int giftiDaNum, con
662
677
}
663
678
else if (type == MRIS_GIFTI_FILE)
664
679
{
665
- // ??? is curv_fname set for this code path ???
666
- MRISwriteGIFTI (mris, NIFTI_INTENT_SHAPE, out_fname, fcurv);
680
+ MRISwriteGIFTI (mris, NIFTI_INTENT_SHAPE, out_fname, NULL );
667
681
}
668
682
else
669
683
{
@@ -842,6 +856,10 @@ get_option(int argc, char *argv[])
842
856
nargs = 1 ;
843
857
#endif
844
858
}
859
+ else if (!stricmp (option, " -mergegifti" ))
860
+ {
861
+ mergegifti_flag = 1 ;
862
+ }
845
863
else if (!stricmp (option, " -delete-cmds" ))
846
864
{
847
865
DeleteCommands = 1 ;
@@ -915,10 +933,30 @@ get_option(int argc, char *argv[])
915
933
nargs = 1 ;
916
934
break ;
917
935
case ' C' :
936
+ {
918
937
curv_file_flag = 1 ;
919
938
curv_fname = argv[2 ] ;
920
939
nargs = 1 ;
940
+
941
+ int argc0 = 2 ;
942
+ int nth = 3 ;
943
+ // get additional input curvature files
944
+ // minus 2 positional arguments
945
+ while (nth_is_arg (argc-nth-2 , argv, nth))
946
+ {
947
+ nargs++; nth++;
948
+ }
949
+
950
+ arr_fcurv = new const char *[nargs];
951
+ for (int n = 0 ; n < nargs; n++)
952
+ {
953
+ arr_fcurv[n] = argv[argc0];
954
+ argc0++;
955
+ }
956
+
957
+ nfcurv = nargs;
921
958
break ;
959
+ }
922
960
case ' N' :
923
961
output_normals = 1 ;
924
962
break ;
@@ -964,6 +1002,12 @@ get_option(int argc, char *argv[])
964
1002
965
1003
static void check_options (void )
966
1004
{
1005
+ if (combinesurfs_flag && curv_file_flag)
1006
+ {
1007
+ printf (" ERROR: --combinesurf and -c are mutually exclusive. \n " );
1008
+ exit (1 );
1009
+ }
1010
+
967
1011
// --to-scanner/--userealras and --to-tkr/--usesurfras are mutually exclusive
968
1012
if ( (ToScanner || userealras_flag) &&
969
1013
(ToTkr || usesurfras_flag) )
@@ -991,7 +1035,31 @@ static void check_options(void)
991
1035
}
992
1036
}
993
1037
994
- static void
1038
+ /* ---------------------------------------------------------------*/
1039
+ static int isflag (char *flag) {
1040
+ int len;
1041
+ len = strlen (flag);
1042
+ if (len < 2 ) return (0 );
1043
+
1044
+ if (flag[0 ] == ' -' && flag[1 ] == ' -' ) return (1 );
1045
+ return (0 );
1046
+ }
1047
+
1048
+ /* ---------------------------------------------------------------*/
1049
+ static int nth_is_arg (int nargc, char **argv, int nth) {
1050
+ /* Checks that nth arg exists and is not a flag */
1051
+ /* nth is 0-based */
1052
+
1053
+ /* check that there are enough args for nth to exist */
1054
+ if (nargc <= 0 ) return (0 );
1055
+
1056
+ /* check whether the nth arg is a flag */
1057
+ if (isflag (argv[nth])) return (0 );
1058
+
1059
+ return (1 );
1060
+ }
1061
+
1062
+ static void
995
1063
usage_exit (void )
996
1064
{
997
1065
print_help () ;
0 commit comments