I want to know if there is any AFNI function to read the header information from a X1D file.
Specifically, I want to read the “ColumnLabels” in the attached x1D ( x1D ), so that I can find extract label names and their corresponding Betas and T statistic for trial wise data using Stim_Times_IM.
Note that as a naming convention, we normally use .1D as the file extension, but the program will still read something called .x1D.
You can extract columns using the header labels:
# extract two columns using labels
1d_tool.py \
-infile PCR501_M_TR_MNI_3mm_SI_censor_CueCSPLINTaskMR.x1D'[Run#1Pol#0,Run#1Pol#1]' \
-write testA.1D
# extract a slice/interval of columns with '..'
1d_tool.py \
-infile PCR501_M_TR_MNI_3mm_SI_censor_CueCSPLINTaskMR.x1D'[Run#1Pol#0..Run#1Pol#4]' \
-write testB.1D
Sidenote: I think we need to update the second case in Ex. 1 of the help file to use .., not ,, for the slice interval specification, as I have used above.
How do I extract the column label names along with the data. ( asking for this because the number of column labels change with participant, especially when I use stim_times_IM based on accuracy )
I have a Linux-y command line way of getting a list of column headers, but @rickr might have a more official one.
In this example, I'm using X.stim.xmat.1D from the AFNI Bootcamp example. To see what the text file row in question looks like, we can use grep to extract it:
Note that I put a \ before the grep command up above, to avoid having colors in the text string as we process.
So, now we see we want to make the list by: 1) taking everythign to the right of the =, then removing the " (which could mean replacing it with a null character), then splitting at ; to make a list (which means replacing ';' with a newline character). This is accomplished by successively piping like this:
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.