1 /**---------------------------------------------------------------------------
2 Setup for realtime callback, which will be invoked every time
3 AFNI is 'told' about new datasets (i.e., per 'update' # of TRs):
4
5 + set global afni variable
6 GLOBAL_library.realtime_callback = your_function_name
7 will be invoked as
8 your_function_name(void *junk) ; [[junk will be NULL]]
9
10 + to find out what's up, query the global afni variable
11 RT_status *GLOBAL_library.realtime_status
12 described below; each dataset should have the same number of volumes
13 (cf. the trivial test callback at the bottom to grok what's happening)
14
15 + status will be RT_STARTUP at first call, and there will be data
16 in the datasets at that time
17 + status will be RT_CONTINUE at subsequent calls (with new data)
18 + status will be RT_FINISHED when this acquisition is over; the next
19 time the realtime callback is invoked, status should be RT_STARTUP
20 and there should be an entirely new set of dataset pointers to play with
21 ---------------------------------------------------------------------------**/
22
23 typedef struct {
24 int numchan ; /* number of channels from scanner */
25 int status ; /* one of the RT_ codes below */
26 int numdset ; /* total number of datasets below */
27 THD_3dim_dataset **dset ; /* array of pointers to datasets */
28 } RT_status ;
29
30 #define RT_STARTUP 1 /* status codes [01 Jun 2009] */
31 #define RT_CONTINUE 2
32 #define RT_FINISHED 3
33
34 /**---------------------------------------------------------------------------
35 Dataset order in RT_status struct:
36 + 0..numchan-1 = channels from scanner
37 + if channel merger is on, then merged channel is next
38 + if registration is on, then registered dataset is last
39 + so normally, dset[numdset-1] is the one you want for SVM-ization
40 ---------------------------------------------------------------------------**/
41
42 /*-------------------------------------------------------------------------*/
43 /* Test realtime_callback function [01 Jun 2009] */
44
RT_test_callback(void * junk)45 void RT_test_callback(void *junk)
46 {
47 RT_status *rts = GLOBAL_library.realtime_status ;
48 int cc , nval,nbr ;
49
50 if( rts == NULL ){ ERROR_message("bad call to RT_test_callback"); return; }
51
52 INFO_message("RT_test_callback: numchan=%d status=%d numdset=%d",
53 rts->numchan , rts->status , rts->numdset ) ;
54
55 for( cc=0 ; cc < rts->numdset ; cc++ ){ /* print out some dataset info */
56 if( !ISVALID_DSET(rts->dset[cc]) ){
57 ININFO_message(" dset[%d] invalid!",cc) ; /* should never happen */
58 } else {
59 nval = DSET_NVALS(rts->dset[cc]) ; /* number of bricks */
60 nbr = THD_count_databricks(rts->dset[cc]->dblk) ; /* number with data */
61 ININFO_message(" dset[%d] '%s': nvals=%d nbr=%d",
62 cc , DSET_HEADNAME(rts->dset[cc]) , nval,nbr ) ;
63 }
64 }
65 return ;
66 }
67