Doxygen Source Code Documentation
afni_niml.c File Reference
#include "afni.h"
#include "vol2surf.h"
Go to the source code of this file.
Define Documentation
|
Definition at line 117 of file afni_niml.c. Referenced by AFNI_niml_viewpoint_CB(). |
|
Connected flag Definition at line 64 of file afni_niml.c. Referenced by AFNI_niml_workproc(). |
|
Skip flag Definition at line 68 of file afni_niml.c. Referenced by AFNI_niml_workproc(). |
|
Waiting for connection flag Definition at line 60 of file afni_niml.c. Referenced by AFNI_niml_workproc(). |
|
Definition at line 112 of file afni_niml.c. Referenced by AFNI_init_niml(). |
|
The SUMA stream index in ns_listen Definition at line 73 of file afni_niml.c. Referenced by AFNI_niml_redisplay_CB(), and AFNI_niml_viewpoint_CB(). |
|
Number of streams on which to listen Definition at line 41 of file afni_niml.c. Referenced by AFNI_init_niml(), AFNI_niml_atexit(), and AFNI_niml_workproc(). |
|
Value: do{ if( g_show_as_popup == 1 ) AFNI_popup_message(mmm); \ else if( g_show_as_popup == 0 ) fputs(mmm,stderr) ; } while(0) Definition at line 98 of file afni_niml.c. Referenced by process_NIML_AFNI_dataset(), process_NIML_AFNI_volumedata(), process_NIML_Node_ROI(), process_NIML_SUMA_crosshair_xyz(), process_NIML_SUMA_ijk(), process_NIML_SUMA_ixyz(), and process_NIML_SUMA_node_normals(). |
Function Documentation
|
Definition at line 573 of file afni_niml.c. References dont_overlay_suma. Referenced by AFNI_see_func_CB().
00574 { 00575 dont_overlay_suma = aa ; 00576 } |
|
Definition at line 1164 of file afni_niml.c. References AFNI_find_closest_node(), Three_D_View::anat_now, AXIAL, CORONAL, DSET_DX, DSET_DY, DSET_DZ, SUMA_ixyz::id, IM3D_OPEN, SUMA_surface::ixyz, LOAD_FVEC3, SUMA_surface::num_ixyz, SAGITTAL, Three_D_View::ss_now, THD_session::su_num, THD_session::su_surf, THD_3dmm_to_dicomm(), AFNI_view_info::view_setter, Three_D_View::vinfo, AFNI_view_info::xi, THD_fvec3::xyz, AFNI_view_info::yj, and AFNI_view_info::zk. Referenced by AFNI_brick_to_mri(), and AFNI_niml_viewpoint_CB().
01165 { 01166 Three_D_View *im3d = (Three_D_View *)qq3d ; 01167 int ks , kbest=-1,ibest=-1 ,ii , nnod ; 01168 float xyz[3] , dbest=WAY_BIG,dd , xbot,xtop,ybot,ytop,zbot,ztop ; 01169 SUMA_surface *ag ; 01170 SUMA_ixyz *nod ; 01171 01172 if( !IM3D_OPEN(im3d) || (kkbest==NULL && iibest==NULL) ) return ; 01173 if( im3d->ss_now->su_num == 0 || 01174 im3d->ss_now->su_surf[0] == NULL ) return ; 01175 01176 xyz[0] = im3d->vinfo->xi ; /* current RAI coordinates */ 01177 xyz[1] = im3d->vinfo->yj ; 01178 xyz[2] = im3d->vinfo->zk ; 01179 01180 /* 20 Feb 2003: find closest node */ 01181 01182 xbot = ybot = zbot = xtop = ytop = ztop = 0.0 ; /* unrestricted */ 01183 01184 if( im3d->vinfo->view_setter > 0 ){ /* restrict to a thick plane */ 01185 THD_fvec3 fv ; 01186 LOAD_FVEC3(fv,DSET_DX(im3d->anat_now), 01187 DSET_DY(im3d->anat_now),DSET_DZ(im3d->anat_now)) ; 01188 fv = THD_3dmm_to_dicomm(im3d->anat_now,fv) ; 01189 switch( im3d->vinfo->view_setter ){ 01190 case AXIAL: 01191 dd = 0.499*fabs(fv.xyz[2]) ; zbot = xyz[2]-dd ; ztop = xyz[2]+dd ; 01192 break ; 01193 case SAGITTAL: 01194 dd = 0.499*fabs(fv.xyz[0]) ; xbot = xyz[0]-dd ; xtop = xyz[0]+dd ; 01195 break ; 01196 case CORONAL: 01197 dd = 0.499*fabs(fv.xyz[1]) ; ybot = xyz[1]-dd ; ytop = xyz[1]+dd ; 01198 break ; 01199 } 01200 #if 0 01201 fprintf(stderr,"view_setter=%d box=%f,%f %f,%f %f,%f\n", 01202 im3d->vinfo->view_setter , xbot,xtop,ybot,ytop,zbot,ztop ) ; 01203 #endif 01204 } 01205 01206 /* search all surfaces */ 01207 01208 for( ks=0 ; ks < im3d->ss_now->su_num ; ks++ ){ 01209 ag = im3d->ss_now->su_surf[ks]; if( ag == NULL ) continue; 01210 nod = ag->ixyz ; nnod = ag->num_ixyz ; 01211 ii = AFNI_find_closest_node( nnod,nod , xyz[0],xyz[1],xyz[2] , 01212 xbot,xtop,ybot,ytop,zbot,ztop ) ; 01213 if( ii >= 0 ){ 01214 dd = sqrt( (xyz[0]-nod[ii].x)*(xyz[0]-nod[ii].x) 01215 +(xyz[1]-nod[ii].y)*(xyz[1]-nod[ii].y) 01216 +(xyz[2]-nod[ii].z)*(xyz[2]-nod[ii].z) ) ; 01217 if( kbest < 0 || dd < dbest ){ 01218 kbest = ks ; ibest = ii ; dbest = dd ; 01219 } 01220 } 01221 } 01222 01223 /* if didn't find anything, try again unrestricted */ 01224 if( kbest < 0 && im3d->vinfo->view_setter > 0 ){ 01225 xbot = ybot = zbot = xtop = ytop = ztop = 0.0 ; 01226 for( ks=0 ; ks < im3d->ss_now->su_num ; ks++ ){ 01227 ag = im3d->ss_now->su_surf[ks]; if( ag == NULL ) continue; 01228 nod = ag->ixyz ; nnod = ag->num_ixyz ; 01229 ii = AFNI_find_closest_node( nnod,nod , xyz[0],xyz[1],xyz[2] , 01230 xbot,xtop,ybot,ytop,zbot,ztop ) ; 01231 if( ii >= 0 ){ 01232 dd = sqrt( (xyz[0]-nod[ii].x)*(xyz[0]-nod[ii].x) 01233 +(xyz[1]-nod[ii].y)*(xyz[1]-nod[ii].y) 01234 +(xyz[2]-nod[ii].z)*(xyz[2]-nod[ii].z) ) ; 01235 if( kbest < 0 || dd < dbest ){ 01236 kbest = ks ; ibest = ii ; dbest = dd ; 01237 } 01238 } 01239 } 01240 } 01241 01242 if( kbest >= 0 ){ 01243 ag = im3d->ss_now->su_surf[kbest] ; nod = ag->ixyz ; 01244 ibest = nod[ibest].id ; 01245 } 01246 01247 if( kkbest != NULL ) *kkbest = kbest ; 01248 if( iibest != NULL ) *iibest = ibest ; 01249 return ; 01250 } |
|
Initialize NIML listening. ------------------------------------------------------------------------- Definition at line 212 of file afni_niml.c. References AFNI_niml_atexit(), AFNI_niml_driver(), AFNI_niml_redisplay_CB(), AFNI_niml_viewpoint_CB(), AFNI_niml_workproc(), AFNI_numenv(), AFNI_receive_init(), AFNI_yesenv(), atexit(), AFNI_library_type::controllers, ENTRY, g_show_as_popup, GLOBAL_argopt, GLOBAL_library, MAX_CONTROLLERS, NI_register_doer(), NIML_TCP_FIRST_PORT, ns_flags, ns_name, NUM_NIML, PLUTO_register_workproc(), AF_options::port_niml, RECEIVE_FUNCDISPLAY_MASK, RECEIVE_VIEWPOINT_MASK, redisplay_key, sendit, serrit, started, and viewpoint_key. Referenced by AFNI_misc_CB(), and AFNI_startup_timeout_CB().
00213 { 00214 int cc , ii ; 00215 00216 ENTRY("AFNI_init_niml") ; 00217 00218 if( started ) EXRETURN ; 00219 00220 PLUTO_register_workproc( AFNI_niml_workproc , NULL ) ; 00221 #if 0 00222 atexit( AFNI_niml_atexit ) ; 00223 #endif 00224 00225 /* initialize status and names of all listening NI_streams */ 00226 00227 for( cc=0 ; cc < NUM_NIML ; cc++ ){ 00228 ns_listen[cc] = NULL ; 00229 ns_flags[cc] = 0 ; 00230 } 00231 00232 /* 10 Dec 2002: allow user to specify NIML port number */ 00233 00234 cc = GLOBAL_argopt.port_niml ; 00235 if( cc < 1024 || cc > 65535 ) cc = SUMA_TCP_PORT ; 00236 sprintf( ns_name[0] , "tcp:host:%d" , cc ) ; 00237 00238 /* 09 Mar 2005: add extra ports */ 00239 00240 cc = AFNI_numenv( "AFNI_NIML_FIRST_PORT" ) ; 00241 if( cc < 1024 || cc > 65535 ) cc = NIML_TCP_FIRST_PORT ; 00242 for( ii=1 ; ii < NUM_NIML ; ii++ ) 00243 sprintf( ns_name[ii] , "tcp:host:%d" , (cc+ii-1) ) ; 00244 00245 /* initialize all receive keys (cf. afni_receive.c) */ 00246 00247 for( cc=0 ; cc < MAX_CONTROLLERS ; cc++ ){ 00248 redisplay_key[cc] = -1 ; 00249 viewpoint_key[cc] = -1 ; 00250 } 00251 00252 /* set up to receive notifications (callbacks) 00253 when the functional overlay is redisplayed (controller A only) */ 00254 00255 redisplay_key[0] = AFNI_receive_init( GLOBAL_library.controllers[0] , 00256 RECEIVE_FUNCDISPLAY_MASK , 00257 AFNI_niml_redisplay_CB , 00258 GLOBAL_library.controllers[0] , 00259 "AFNI_niml_redisplay_CB" ) ; 00260 00261 /* set up to receive notifications (callbacks) 00262 when the viewpoint is altered by the user (controller A only) */ 00263 00264 viewpoint_key[0] = AFNI_receive_init( GLOBAL_library.controllers[0] , 00265 RECEIVE_VIEWPOINT_MASK , 00266 AFNI_niml_viewpoint_CB , 00267 GLOBAL_library.controllers[0] , 00268 "AFNI_niml_viewpoint_CB" ) ; 00269 00270 /* determine if we actually want to send data */ 00271 00272 sendit = !AFNI_yesenv("AFNI_NIML_DONTSEND") ; 00273 serrit = !sendit || AFNI_yesenv("AFNI_NIML_STDERR") ; /* debugging */ 00274 00275 /* 12 Feb 2003: setup ni_do "DRIVE_AFNI" verb */ 00276 00277 NI_register_doer( "DRIVE_AFNI" , AFNI_niml_driver ) ; 00278 00279 /* 04 Jan 2005 [rickr]: check for AFNI_SHOW_SURF_POPUPS */ 00280 00281 if( AFNI_yesenv("AFNI_SHOW_SURF_POPUPS") ) g_show_as_popup = 1 ; 00282 else if( AFNI_yesenv("AFNI_KILL_SURF_POPUPS") ) g_show_as_popup = -1 ; 00283 00284 /* and we're off to see the wizard */ 00285 00286 started = 1 ; EXRETURN ; 00287 } |
|
Routine executed at AFNI exit: shutdown all open NI_stream. ------------------------------------------------------------------------- Definition at line 197 of file afni_niml.c. References NI_stream_closenow(), NUM_NIML, and STATUS. Referenced by AFNI_init_niml().
00198 { 00199 #if 0 /*** this stuff now handled in niml/niml_stream.c ***/ 00200 int cc ; 00201 STATUS("called AFNI_niml_atexit") ; 00202 for( cc=0 ; cc < NUM_NIML ; cc++ ) /* close any open sockets */ 00203 NI_stream_closenow( ns_listen[cc] ) ; 00204 #endif 00205 return ; 00206 } |
|
Drive AFNI from a NIML element. [12 Feb 2003] Definition at line 292 of file afni_niml.c. References AFNI_driver(), and object. Referenced by AFNI_init_niml().
00293 { 00294 (void) AFNI_driver( object ) ; 00295 return ; 00296 } |
|
Receives notice when user redisplays the functional overlay. ---------------------------------------------------------------------- Definition at line 582 of file afni_niml.c. References SUMA_irgba::a, AFNI_vol2surf_func_overlay(), Three_D_View::anat_now, SUMA_irgba::b, bcol, disp_ldp_surf_list(), dont_overlay_suma, dont_tell_suma, ENTRY, fill_ldp_surf_list(), Three_D_View::fim_now, free, AFNI_view_info::func_visible, SUMA_irgba::g, GLOBAL_argopt, SUMA_irgba::id, THD_3dim_dataset::idcode, SUMA_surface::idcode, SUMA_surface::idcode_ldp, IM3D_OPEN, LDP_list::list, MV_format_fval(), NI_add_column(), NI_BINARY_MODE, NI_BYTE, NI_clock_time(), NI_FLOAT, NI_free_element(), NI_INT, NI_new_data_element(), NI_set_attribute(), NI_stream_goodcheck(), NI_write_element(), NIML_to_stderr(), NS_SUMA, ldp_surf_list::nsurf, LDP_list::nused, SUMA_vnlist::nvox, q, SUMA_irgba::r, ldp_surf_list::sA, ldp_surf_list::sB, serrit, Three_D_View::ss_now, MCW_idcode::str, THD_session::su_num, THD_session::su_surf, ldp_surf_list::use_v2s, NI_element::vec, Three_D_View::vinfo, SUMA_surface::vn, and AF_options::yes_niml. Referenced by AFNI_init_niml().
00583 { 00584 static LDP_list ldp_list = { NULL, 0, 0 }; /* 07 Oct 2004 [rickr] */ 00585 Three_D_View *im3d = (Three_D_View *) qqq ; 00586 THD_3dim_dataset *adset , *fdset ; 00587 SUMA_irgba *map ; 00588 float *rdata, rthresh ; 00589 int nmap, nvtot , ct , kldp ; 00590 int sA, sB; 00591 NI_element *nel ; 00592 char msg[16] ; 00593 THD_session *sess ; /* 20 Jan 2004 */ 00594 00595 ENTRY("AFNI_niml_redisplay_CB") ; 00596 00597 /* check inputs for reasonability */ 00598 00599 if( dont_tell_suma || 00600 dont_overlay_suma || 00601 !IM3D_OPEN(im3d) || 00602 !im3d->vinfo->func_visible ) EXRETURN ; 00603 00604 sess = im3d->ss_now ; if( sess->su_num == 0 ) EXRETURN ; 00605 adset = im3d->anat_now ; 00606 fdset = im3d->fim_now ; if( fdset == NULL ) EXRETURN ; 00607 00608 if( sendit ){ 00609 if( NI_stream_goodcheck(ns_listen[NS_SUMA],1) < 1 ) EXRETURN ; 00610 } 00611 00612 /* build a node+color map */ 00613 00614 ct = NI_clock_time() ; 00615 00616 if ( gv2s_plug_opts.sopt.debug > 0 || gv2s_plug_opts.sopt.dnode >= 0 ) 00617 fprintf(stderr, 00618 "============================================================\n"); 00619 00620 if( fill_ldp_surf_list(&ldp_list, sess, &gv2s_plug_opts) != 0 ) 00621 EXRETURN ; 00622 00623 if( gv2s_plug_opts.sopt.debug > 1 ) /* spit out some info */ 00624 disp_ldp_surf_list(&ldp_list, sess); 00625 00626 /* 07 Oct 2004 [rickr] 00627 Now we loop over all local domain parents in the current session 00628 and send the node+color map for each and every one! */ 00629 for( kldp=0 ; kldp < ldp_list.nused ; kldp++ ){ 00630 00631 /* For each LDP, if use_v2s, use it 00632 * else if one surface, use afni 00633 * else, call vol2surf w/midpoint on the 2 surfaces 00634 * 07 Oct 2004 [rickr] */ 00635 00636 sA = ldp_list.list[kldp].sA; /* for the sake of laziness */ 00637 sB = ldp_list.list[kldp].sB; 00638 00639 rdata = NULL; /* if we want these values, send them to A_vol2surf */ 00640 rthresh = 0.0; 00641 00642 if( ldp_list.list[kldp].use_v2s ){ /* vol2surf was requested */ 00643 nmap = AFNI_vol2surf_func_overlay(im3d, &map, sA,sB, 0, NULL, &rthresh); 00644 } else if ( ldp_list.list[kldp].nsurf > 1 ){ /* use v2s with defaults */ 00645 nmap = AFNI_vol2surf_func_overlay(im3d, &map, sA,sB, 1, NULL, &rthresh); 00646 } else { /* one surface, no request: use vnlist */ 00647 /* okay, no more vnlist... :( 25 Oct 2004 [rickr] */ 00648 /* nmap = AFNI_vnlist_func_overlay( im3d, sA, &map,&nvused ) ; */ 00649 00650 nmap = AFNI_vol2surf_func_overlay(im3d, &map, sA, -1, 1, NULL, &rthresh); 00651 } 00652 00653 #if 0 00654 if( serrit ) fprintf(stderr,"AFNI_niml_redisplay_CB: nmap=%d\n",nmap) ; 00655 00656 /* we always use v2s now */ 00657 if( ! v2s && ( nmap < 0 || sess->su_surf[sA]->vn == NULL ) ) 00658 { 00659 if( gv2s_plug_opts.sopt.debug > 0 ) 00660 fprintf(stderr,"** afni: bad surface %d, ret: %d,%p\n", sA, nmap, map); 00661 continue ; /* this is bad */ 00662 } 00663 #endif 00664 00665 /* base the error checking on which mapping method was used */ 00666 if( nmap < 0 || (nmap > 0 && !map) ) /* 29 Sep 2004 [rickr] */ 00667 { 00668 if( gv2s_plug_opts.sopt.debug > 0 ) 00669 fprintf(stderr,"** bad v2s map %d, ret: %d,%p\n", sA, nmap, map); 00670 continue ; /* this is bad */ 00671 } 00672 00673 if( nmap > 0 ){ /*--- make a data element with data ---*/ 00674 00675 int *icol ; byte *rcol, *gcol, *bcol, *acol ; int ii ; 00676 00677 nel = NI_new_data_element( "SUMA_irgba" , nmap ) ; 00678 00679 /* adding a NULL column creates it, full of zeros */ 00680 00681 NI_add_column( nel , NI_INT , NULL ) ; icol = nel->vec[0] ; 00682 NI_add_column( nel , NI_BYTE , NULL ) ; rcol = nel->vec[1] ; 00683 NI_add_column( nel , NI_BYTE , NULL ) ; gcol = nel->vec[2] ; 00684 NI_add_column( nel , NI_BYTE , NULL ) ; bcol = nel->vec[3] ; 00685 NI_add_column( nel , NI_BYTE , NULL ) ; acol = nel->vec[4] ; 00686 00687 #if 0 /* just as a reminder, will we send the data to suma? */ 00688 if( rdata ){ 00689 if( gv2s_plug_opts.sopt.debug > 1 ) 00690 fprintf(stderr,"-d sending data and thresh (%f) to suma\n",rthresh); 00691 NI_add_column( nel , NI_FLOAT, rdata ) ; 00692 free(rdata) ; 00693 rdata = NULL ; 00694 } 00695 #endif 00696 00697 for( ii=0 ; ii < nmap ; ii++ ){ /* copy data into element */ 00698 icol[ii] = map[ii].id ; 00699 rcol[ii] = map[ii].r ; gcol[ii] = map[ii].g ; 00700 bcol[ii] = map[ii].b ; acol[ii] = map[ii].a ; 00701 } 00702 00703 free(map) ; /* data in nel, so don't need map no more */ 00704 00705 } else { /*--- make an empty data element ---*/ 00706 00707 nel = NI_new_data_element( "SUMA_irgba" , 0 ) ; 00708 } 00709 00710 if ( sess->su_surf[sA]->vn ) /* 29 Sep 2004 [rickr] */ 00711 nvtot = sess->su_surf[sA]->vn->nvox ; /* 13 Mar 2002 and 20 Jan 2004 */ 00712 else 00713 nvtot = -1; /* make it clear, vol2surf has no interface for this */ 00714 00715 /* 13 Mar 2002: send idcodes of surface and datasets involved */ 00716 00717 NI_set_attribute( nel, "surface_idcode" , sess->su_surf[sA]->idcode ) ; 00718 NI_set_attribute( nel, "local_domain_parent_ID" , 00719 sess->su_surf[sA]->idcode_ldp ) ; 00720 NI_set_attribute( nel, "volume_idcode" , adset->idcode.str ) ; 00721 NI_set_attribute( nel, "function_idcode", fdset->idcode.str ) ; 00722 00723 /* 13 Mar 2002: also send the number of voxels in the surface 00724 and the number of voxels that were colored in */ 00725 00726 if( nvtot >= 0 ) { 00727 sprintf(msg,"%d",nvtot) ; 00728 NI_set_attribute( nel , "numvox_total" , msg ) ; 00729 } 00730 00731 #if 0 /* we no longer have this number */ 00732 if ( nvused >= 0 ) { 00733 sprintf(msg,"%d",nvused) ; 00734 NI_set_attribute( nel , "numvox_used" , msg ) ; 00735 } 00736 #endif 00737 00738 /* 22 Oct 2004: pass the threshold (only works for vol2surf now!) */ 00739 NI_set_attribute( nel , "threshold" , MV_format_fval(rthresh)) ; 00740 00741 if( sendit ) 00742 NI_write_element( ns_listen[NS_SUMA] , nel , NI_BINARY_MODE ) ; 00743 if( serrit ) 00744 NIML_to_stderr(nel,1) ; 00745 00746 #if 0 00747 if( serrit || GLOBAL_argopt.yes_niml > 1 ) 00748 fprintf(stderr, 00749 "++ NIML write colored surface: voxels=%d nodes=%d time=%d ms\n", 00750 nvused , nmap , ct = NI_clock_time() - ct ) ; 00751 #endif 00752 00753 NI_free_element(nel) ; /* it's gone, so forget it */ 00754 00755 } /* end of loop over surface in session */ 00756 00757 EXRETURN ; 00758 } |
|
Receives notice when user changes viewpoint position. ---------------------------------------------------------------------- Definition at line 1100 of file afni_niml.c. References AFNI_get_xhair_node(), Three_D_View::anat_now, dont_tell_suma, ENTRY, EPS, THD_3dim_dataset::idcode, SUMA_surface::idcode, IM3D_OPEN, NI_add_column(), NI_FLOAT, NI_free_element(), NI_new_data_element(), NI_set_attribute(), NI_stream_goodcheck(), NI_TEXT_MODE, NI_write_element(), NIML_to_stderr(), NS_SUMA, q, Three_D_View::ss_now, MCW_idcode::str, THD_session::su_num, THD_session::su_surf, Three_D_View::vinfo, AFNI_view_info::xi, AFNI_view_info::yj, and AFNI_view_info::zk. Referenced by AFNI_init_niml().
01101 { 01102 Three_D_View *im3d = (Three_D_View *) qqq ; 01103 NI_element *nel ; 01104 float xyz[3] ; 01105 static float xold=-666,yold=-777,zold=-888 ; 01106 int kbest=-1,ibest=-1 ; 01107 01108 ENTRY("AFNI_niml_viewpoint_CB") ; 01109 01110 if( dont_tell_suma || 01111 !IM3D_OPEN(im3d) || 01112 im3d->ss_now->su_num == 0 || 01113 im3d->ss_now->su_surf[0] == NULL ) EXRETURN ; 01114 01115 if( sendit ){ 01116 if( NI_stream_goodcheck(ns_listen[NS_SUMA],1) < 1 ) EXRETURN ; 01117 } 01118 01119 xyz[0] = im3d->vinfo->xi ; /* current RAI coordinates */ 01120 xyz[1] = im3d->vinfo->yj ; 01121 xyz[2] = im3d->vinfo->zk ; 01122 01123 if( fabs(xyz[0]-xold) < EPS && 01124 fabs(xyz[1]-yold) < EPS && 01125 fabs(xyz[2]-zold) < EPS ) EXRETURN ; /* too close to old point */ 01126 01127 /* 20 Feb 2003: find closest node */ 01128 01129 AFNI_get_xhair_node( im3d , &kbest , &ibest ) ; 01130 01131 if( kbest < 0 ) kbest = 0 ; /* default surface */ 01132 01133 /* now send info to SUMA */ 01134 01135 nel = NI_new_data_element( "SUMA_crosshair_xyz" , 3 ) ; 01136 NI_add_column( nel , NI_FLOAT , xyz ) ; 01137 01138 /* 13 Mar 2002: add idcodes of what we are looking at right now */ 01139 01140 NI_set_attribute( nel, "surface_idcode", im3d->ss_now->su_surf[kbest]->idcode ) ; 01141 NI_set_attribute( nel, "volume_idcode" , im3d->anat_now->idcode.str ) ; 01142 01143 /* 20 Feb 2003: set attribute showing closest node ID */ 01144 01145 if( ibest >= 0 ){ 01146 char str[32] ; 01147 sprintf(str,"%d",ibest) ; 01148 NI_set_attribute( nel, "surface_nodeid" , str ) ; 01149 } 01150 01151 xold = xyz[0] ; yold = xyz[1] ; zold = xyz[2] ; /* save old point */ 01152 01153 if( sendit ) 01154 NI_write_element( ns_listen[NS_SUMA] , nel , NI_TEXT_MODE ) ; 01155 if( serrit ) 01156 NIML_to_stderr(nel,1) ; 01157 01158 NI_free_element(nel) ; 01159 EXRETURN ; 01160 } |
|
NIML workprocess.
Definition at line 326 of file afni_niml.c. References AFNI_driver(), AFNI_process_NIML_data(), dont_overlay_suma, dont_tell_suma, ENTRY, FLAG_CONNECTED, FLAG_SKIP, FLAG_WAITING, NI_procins::name, NI_BUFSIZE, NI_clock_time(), NI_element_type(), NI_free_element(), NI_get_attribute(), NI_PROCINS_TYPE, NI_read_element(), NI_stream_closenow(), NI_stream_goodcheck(), NI_stream_hasinput(), NI_stream_name(), NI_stream_open(), NI_stream_setbufsize(), NIML_to_stderr(), ns_flags, ns_name, NUM_NIML, RETURN, and STATUS. Referenced by AFNI_init_niml().
00327 { 00328 int cc , nn , ct , ngood=0 ; 00329 void *nini ; 00330 char str[512] ; 00331 int keep_reading , read_msec ; /* 17 Mar 2005 */ 00332 00333 ENTRY("AFNI_niml_workproc") ; 00334 00335 /** loop over input NIML streams **/ 00336 00337 for( cc=0 ; cc < NUM_NIML ; cc++ ){ 00338 00339 keep_reading = 0 ; /* 17 Mar 2005 */ 00340 00341 /* open streams that aren't open */ 00342 00343 if( ns_listen[cc] == NULL && (ns_flags[cc]&FLAG_SKIP)==0 ){ 00344 if(PRINT_TRACING){ 00345 sprintf(str,"call NI_stream_open('%s')",ns_name[cc]) ; 00346 STATUS(str) ; 00347 } 00348 00349 ns_listen[cc] = NI_stream_open( ns_name[cc] , "r" ) ; 00350 00351 if( ns_listen[cc] == NULL ){ 00352 STATUS("NI_stream_open failed") ; 00353 ns_flags[cc] = FLAG_SKIP ; continue ; /* skip to next NIML stream */ 00354 } 00355 ns_flags[cc] = FLAG_WAITING ; 00356 } 00357 if( ns_listen[cc] == NULL ) continue ; /* this is Ziad's fault! */ 00358 00359 ngood++ ; 00360 00361 /* now check if stream has gone bad */ 00362 00363 if(PRINT_TRACING){ 00364 sprintf(str,"call NI_stream_goodcheck('%s')",ns_listen[cc]->orig_name); 00365 STATUS(str) ; 00366 } 00367 00368 /* 17 Mar 2005: loopback point if instructed to keep reading */ 00369 00370 Keep_Reading: 00371 read_msec = (keep_reading) ? 222 : 1 ; /* 1/3 of the Beast! */ 00372 00373 nn = NI_stream_goodcheck( ns_listen[cc] , 1 ) ; 00374 00375 if( nn < 0 ){ /* is bad */ 00376 STATUS("NI_stream_goodcheck was unhappy") ; 00377 fprintf(stderr,"++ NIML connection closed from %s\n", 00378 NI_stream_name(ns_listen[cc]) ) ; 00379 00380 NI_stream_closenow( ns_listen[cc] ) ; 00381 ns_listen[cc] = NULL ; /* will be reopened next time */ 00382 ns_flags[cc] = 0 ; 00383 keep_reading = 0 ; 00384 continue ; /* skip to next stream */ 00385 } 00386 00387 if( nn == 0 ){ 00388 STATUS("NI_stream_goodcheck was neutral") ; 00389 keep_reading = 0 ; 00390 continue ; /* waiting: skip to next stream */ 00391 } 00392 00393 /* if here, stream is good */ 00394 00395 STATUS("NI_stream_goodcheck was good!") ; 00396 00397 /* if just became good, print a message */ 00398 00399 if( ns_flags[cc] & FLAG_WAITING ){ 00400 ns_flags[cc] = FLAG_CONNECTED ; 00401 NI_stream_setbufsize( ns_listen[cc] , 3*NI_BUFSIZE ) ; /* 02 Jun 2005 */ 00402 fprintf(stderr,"++ NIML connection opened from %s\n", 00403 NI_stream_name(ns_listen[cc]) ) ; 00404 } 00405 00406 /* see if there is any data to be read */ 00407 00408 nn = NI_stream_hasinput( ns_listen[cc] , read_msec ) ; 00409 00410 if( nn > 0 ){ /* has data!*/ 00411 STATUS("Reading data!") ; 00412 ct = NI_clock_time() ; /* start timer */ 00413 nini = NI_read_element( ns_listen[cc] , read_msec ) ; /* read it */ 00414 00415 if( nini != NULL ){ /* handle it */ 00416 if( serrit ) NIML_to_stderr(nini,0) ; 00417 00418 /*--- a processing instruction? ---*/ 00419 00420 if( NI_element_type(nini) == NI_PROCINS_TYPE ){ /* 17 Mar 2005 */ 00421 NI_procins *npi = (NI_procins *)nini ; 00422 00423 /* deal with PI's we understand, skip the rest: 00424 "keep_reading" ==> loop back to read again immediately 00425 "pause_reading" ==> turn "keep_reading" off 00426 "drive_afni cmd='stuff'" ==> execute a DRIVE_AFNI command right now */ 00427 00428 if(PRINT_TRACING){ 00429 char sss[256]; sprintf("Processing instruction: '%s'",npi->name); 00430 STATUS(sss) ; 00431 } 00432 if( strcasecmp(npi->name,"keep_reading") == 0 ) 00433 keep_reading = 1 ; 00434 else if( strcasecmp(npi->name,"pause_reading") == 0 ) 00435 keep_reading = 0 ; 00436 else if( strcasecmp(npi->name,"drive_afni") == 0 ){ 00437 char *cmd = NI_get_attribute(npi,"cmd") ; 00438 if( cmd != NULL ) (void) AFNI_driver(cmd) ; 00439 } 00440 00441 /*--- actual data (single element or group)? ---*/ 00442 00443 } else { 00444 00445 STATUS("Actual NIML data!") ; 00446 AFNI_process_NIML_data( cc , nini , ct ) ; /* do something */ 00447 00448 } 00449 00450 STATUS("Freeing NIML element") ; 00451 NI_free_element( nini ) ; /* trash it */ 00452 } 00453 00454 } else keep_reading = 0 ; /* was no data in the read_msec interval */ 00455 00456 if( keep_reading ){ 00457 STATUS("Loopback to Keep_Reading") ; 00458 goto Keep_Reading ; /* try to get another input now! */ 00459 } 00460 00461 } /* end of loop over input NIML streams */ 00462 00463 dont_tell_suma = 0 ; /* talk to SUMA */ 00464 dont_overlay_suma = 0 ; 00465 00466 /* hopefully the following will never happen */ 00467 00468 if( ngood == 0 ){ 00469 fprintf(stderr,"++ NIML shutting down: no listening sockets\n") ; 00470 RETURN( True ) ; 00471 } 00472 00473 RETURN( False ) ; /* normal return: this function will be called again */ 00474 } |
|
Process NIML data. "chan" is the type of stream it came from; this is currently not used. ------------------------------------------------------------------------ Definition at line 481 of file afni_niml.c. References AFNI_popup_message(), ENTRY, NI_element::name, NI_group::name, NI_ELEMENT_TYPE, NI_element_type(), NI_GROUP_TYPE, NI_PROCINS_TYPE, NI_group::part, NI_group::part_num, process_NIML_AFNI_dataset(), process_NIML_AFNI_volumedata(), process_NIML_MRI_IMAGE(), process_NIML_Node_ROI(), process_NIML_SUMA_crosshair_xyz(), process_NIML_SUMA_ijk(), process_NIML_SUMA_ixyz(), process_NIML_SUMA_node_normals(), and tt. Referenced by AFNI_niml_workproc().
00482 { 00483 int tt=NI_element_type(nini) ; 00484 NI_element *nel ; 00485 char msg[256] ; 00486 00487 ENTRY("AFNI_process_NIML_data") ; 00488 00489 if( tt < 0 ) EXRETURN ; /* should never happen */ 00490 00491 if( tt == NI_PROCINS_TYPE ) EXRETURN ; /* 16 Mar 2005 */ 00492 00493 /* we got a group element, so process it */ 00494 00495 if( tt == NI_GROUP_TYPE ){ 00496 NI_group *ngr = (NI_group *) nini ; 00497 00498 /* 10 Mar 2005: add support for 2 types of groups [RWC] */ 00499 00500 if( strcmp(ngr->name,"AFNI_dataset") == 0 ){ 00501 00502 process_NIML_AFNI_dataset( ngr , ct_start ) ; /* AFNI dataset header */ 00503 00504 } else if( strcmp(ngr->name,"VOLUME_DATA") == 0 ){ 00505 00506 process_NIML_AFNI_volumedata( ngr , ct_start ) ; /* AFNI sub-bricks */ 00507 00508 } else { /* the old way: we don't know about this group, 00509 so process the elements within it separately */ 00510 int ii ; 00511 for( ii=0 ; ii < ngr->part_num ; ii++ ) 00512 AFNI_process_NIML_data( chan , ngr->part[ii] , -1 ) ; /* recursion */ 00513 } 00514 00515 EXRETURN ; 00516 } 00517 00518 if( tt != NI_ELEMENT_TYPE ) EXRETURN ; /* should never happen */ 00519 00520 /* if here, have a single data element; 00521 process the data based on the element name */ 00522 00523 nel = (NI_element *)nini ; 00524 00525 #if 0 00526 fprintf(stderr,"AFNI received NIML element name=%s\n",nel->name) ; 00527 #endif 00528 00529 /* broke out as functions, added node_normals 06 Oct 2004 [rickr] */ 00530 00531 if( strcmp(nel->name,"SUMA_ixyz") == 0 ){ 00532 00533 process_NIML_SUMA_ixyz(nel, ct_start) ; /* surface nodes for a dataset */ 00534 00535 } else if( strcmp(nel->name,"SUMA_ijk") == 0 ){ 00536 00537 process_NIML_SUMA_ijk(nel, ct_start) ; /* surface triangles from SUMA */ 00538 00539 } else if( strcmp(nel->name,"SUMA_node_normals") == 0 ){ 00540 00541 process_NIML_SUMA_node_normals(nel, ct_start) ;/* node normals for surf */ 00542 00543 } else if( strcmp(nel->name,"SUMA_crosshair_xyz") == 0 ){ 00544 00545 process_NIML_SUMA_crosshair_xyz(nel) ; /* new focus position */ 00546 00547 } else if( strcmp(nel->name,"Node_ROI") == 0 ){ 00548 00549 process_NIML_Node_ROI(nel, ct_start) ; /* ROI drawing from SUMA */ 00550 00551 } else if( strcmp(nel->name,"VOLUME_DATA") == 0 ){ /* 10 Mar 2005 */ 00552 00553 process_NIML_AFNI_volumedata( nel , ct_start ) ; /* AFNI sub-bricks */ 00554 00555 } else if( strcmp(nel->name,"MRI_IMAGE") == 0 ){ /* 22 Mar 2005 */ 00556 00557 process_NIML_MRI_IMAGE( nel , ct_start ) ; /* store as a .1D file */ 00558 00559 } else { 00560 /*** If here, then name of element didn't match anything ***/ 00561 sprintf(msg,"*** ERROR:\n\n" 00562 " Unknown NIML input: \n" 00563 " <%.222s ...> \n" 00564 " Ignoring it, and hoping it goes away.\n" , 00565 nel->name) ; 00566 AFNI_popup_message(msg) ; 00567 } 00568 EXRETURN ; 00569 } |
|
Display the contents of the LDP_list ---------------------------------------------------------------------- Definition at line 763 of file afni_niml.c. References ENTRY, ldp_surf_list::full_label_ldp, ldp_surf_list::label_ldp, LDP_list::list, LDP_list::nalloc, ldp_surf_list::nsurf, LDP_list::nused, RETURN, ldp_surf_list::sA, ldp_surf_list::sB, and ldp_surf_list::use_v2s. Referenced by AFNI_niml_redisplay_CB().
00764 { 00765 ldp_surf_list * slist; 00766 int ldp; 00767 00768 ENTRY("disp_ldp_surf_list"); 00769 00770 if(!ldp_list || !sess ) { 00771 fprintf(stderr,"** disp_ldp_surf_list: bad params (%p,%p)\n", 00772 ldp_list, sess); 00773 RETURN(1); 00774 } 00775 00776 if( ldp_list->nused <= 0 ){ 00777 fprintf(stderr,"+d LDP_list: empty\n"); 00778 RETURN(0); 00779 } 00780 00781 fprintf(stderr,"+d LDP_list:\n" 00782 " (nused, nalloc) = (%d, %d)\n", 00783 ldp_list->nused, ldp_list->nalloc); 00784 00785 for (ldp = 0, slist = ldp_list->list; ldp < ldp_list->nused; ldp++, slist++ ) 00786 fprintf(stderr," (nsurf,sA,sB,use_v2s) = (%d, %d, %d, %d) : '%s'\n", 00787 slist->nsurf, slist->sA, slist->sB, slist->use_v2s, 00788 slist->full_label_ldp[0] ? slist->full_label_ldp : slist->label_ldp); 00789 RETURN(0); 00790 } |
|
For this session, make a list of surfaces per local domain parent. ---------------------------------------------------------------------- Definition at line 795 of file afni_niml.c. References v2s_opts_t::debug, ENTRY, ldp_surf_list::full_label_ldp, SUMA_surface::idcode_ldp, ldp_surf_list::idcode_ldp, SUMA_surface::label, SUMA_surface::label_ldp, ldp_surf_list::label_ldp, LDP_list::list, LDP_list::nalloc, ldp_surf_list::nsurf, LDP_list::nused, realloc, RETURN, ldp_surf_list::sA, ldp_surf_list::sB, slist_choose_surfs(), v2s_plugin_opts::sopt, THD_session::su_num, THD_session::su_surf, and ldp_surf_list::use_v2s. Referenced by AFNI_niml_redisplay_CB().
00797 { 00798 ldp_surf_list * slist; 00799 int surf, ldp; 00800 00801 ENTRY("fill_ldp_surf_list"); 00802 00803 if(!ldp_list || !sess || !po ) { 00804 fprintf(stderr,"** fill_ldp_surf_list: bad params (%p,%p,%p)\n", 00805 ldp_list, sess, po); 00806 RETURN(1); 00807 } 00808 00809 if ( sess->su_num <= 0 ) RETURN(0); 00810 00811 /* first of all, be slightly wasteful and grow the list to su_num length */ 00812 if( ldp_list->nalloc < sess->su_num ){ 00813 ldp_list->nalloc = sess->su_num; 00814 ldp_list->list = (ldp_surf_list *)realloc(ldp_list->list, 00815 ldp_list->nalloc * sizeof(ldp_surf_list)); 00816 if( !ldp_list->list ){ 00817 fprintf(stderr,"** cannot allocate ldp_list (%d)\n", ldp_list->nalloc); 00818 exit(1); 00819 } 00820 } 00821 00822 /* now, go through the very difficult task of emptying the ldp_list */ 00823 ldp_list->nused = 0; 00824 00825 /* next, fill the list with ldp and their surfaces (beware of O(n^2)...) */ 00826 for ( surf = 0; surf < sess->su_num; surf++ ) { 00827 for ( ldp = 0; ldp < ldp_list->nused; ldp++ ) /* does this ldp exist? */ 00828 if ( strncmp(ldp_list->list[ldp].idcode_ldp, 00829 sess->su_surf[surf]->idcode_ldp,32) == 0 ) 00830 break; 00831 slist = &ldp_list->list[ldp]; /* note where we are */ 00832 00833 if( ldp == ldp_list->nused ){ /* then we have a new ldp */ 00834 slist->idcode_ldp = sess->su_surf[surf]->idcode_ldp; 00835 slist->label_ldp = sess->su_surf[surf]->label_ldp; 00836 slist->full_label_ldp[0] = '\0'; /* init to empty */ 00837 slist->nsurf = 1; /* adding first surface */ 00838 slist->sA = surf; /* the session's surface index */ 00839 slist->sB = -1; /* init to unused */ 00840 slist->use_v2s = 0; /* assume no user request */ 00841 00842 ldp_list->nused++; /* we have added a new ldp entry */ 00843 00844 if ( po->sopt.debug > 2 ) 00845 fprintf(stderr,"+d ldp_list add: ldp '%s', surf #%d '%s'\n", 00846 slist->label_ldp, surf, sess->su_surf[surf]->label); 00847 } else { 00848 slist->nsurf++; 00849 if( slist->nsurf == 2 ) slist->sB = surf; 00850 00851 if ( po->sopt.debug > 2 ) 00852 fprintf(stderr,"+d ldp_list add: ldp '%s', surf #%d '%s'\n", 00853 slist->label_ldp, surf, sess->su_surf[surf]->label); 00854 } 00855 } 00856 00857 (void)slist_choose_surfs(ldp_list, sess, po); 00858 00859 RETURN(0); 00860 } |
|
search list for test_val and return position 21 Oct 2004 [rickr] Definition at line 1017 of file afni_niml.c. References c, ENTRY, and RETURN. Referenced by slist_check_user_surfs().
|
|
Debug printout of a NIML element. ------------------------------------------------------------------------- Definition at line 302 of file afni_niml.c. References NI_ELEMENT_TYPE, NI_element_type(), NI_HEADERONLY_FLAG, NI_stream_closenow(), NI_stream_open(), NI_TEXT_MODE, NI_write_element(), and send.
00303 { 00304 NI_stream ns_err ; 00305 if( NI_element_type(nini) != NI_ELEMENT_TYPE ) return ; 00306 ns_err = NI_stream_open( "stderr:" , "w" ) ; 00307 if( ns_err != NULL ){ 00308 if( send ) 00309 fprintf(stderr,"-------------- AFNI sends NIML element: --------------\n"); 00310 else 00311 fprintf(stderr,"-------------- AFNI gets NIML element: --------------\n"); 00312 NI_write_element( ns_err , nini , NI_TEXT_MODE | NI_HEADERONLY_FLAG ) ; 00313 NI_stream_closenow( ns_err ) ; 00314 } 00315 } |
|
Construct an AFNI dataset from the group element, and insert it into the current session in lowest open controller if it is a new dataset. If it has the same idcode as an old dataset, replace that dataset with this one. ---------------------------------------------------------------------- Definition at line 2141 of file afni_niml.c. References AFNI_find_open_controller(), AFNI_popup_message(), THD_slist_find::dset, DSET_delete, DSET_superlock, THD_session::dsset, ENTRY, GLOBAL_library, THD_3dim_dataset::idcode, NI_clock_time(), THD_session::num_dsset, PLUTO_dset_finder(), POPDOWN_strlist_chooser, AFNI_view_info::sess_num, SHOW_MESSAGE, THD_sessionlist::ssar, AFNI_library_type::sslist, MCW_idcode::str, THD_add_bricks(), THD_MAX_SESSION_SIZE, THD_niml_to_dataset(), THD_update_statistics(), UNDUMMYIZE, THD_3dim_dataset::view_type, and Three_D_View::vinfo. Referenced by AFNI_process_NIML_data().
02142 { 02143 Three_D_View *im3d = AFNI_find_open_controller() ; 02144 THD_3dim_dataset *dset , *old_dset ; 02145 THD_slist_find find ; 02146 THD_session *ss ; 02147 int ii , vv , ww ; 02148 02149 int ct_read = 0, ct_tot = 0 ; 02150 char msg[1024] ; 02151 02152 ENTRY("process_NIML_AFNI_dataset") ; 02153 02154 if( ct_start >= 0 ) ct_read = NI_clock_time() - ct_start ; 02155 02156 /* convert the group element contents into a dataset */ 02157 02158 dset = THD_niml_to_dataset( ngr , 1 ) ; /* 1 ==> don't load sub-bricks */ 02159 if( dset == NULL ){ 02160 AFNI_popup_message("\n*** ERROR:\n" 02161 " Received bad '<AFNI_dataset ...>'\n" 02162 " Discarding data and continuing.\n" ) ; 02163 EXRETURN ; 02164 } 02165 02166 /* now see if this dataset idcode is already stored in AFNI somewhere */ 02167 02168 find = PLUTO_dset_finder( dset->idcode.str ) ; old_dset = find.dset ; 02169 02170 if( old_dset == NULL ){ /********* this is a new dataset *************/ 02171 02172 ss = GLOBAL_library.sslist->ssar[im3d->vinfo->sess_num] ; /* session */ 02173 ii = ss->num_dsset ; /* row */ 02174 vv = dset->view_type ; /* and view */ 02175 02176 if( ii >= THD_MAX_SESSION_SIZE ){ /* session overflow! */ 02177 DSET_delete(dset) ; 02178 AFNI_popup_message("\n*** ERROR:\n" 02179 " Received new dataset but am out of space!\n\n" ) ; 02180 EXRETURN ; 02181 } 02182 02183 ss->dsset[ii][vv] = dset ; /*** insert dataset into session here ***/ 02184 ss->num_dsset++ ; 02185 POPDOWN_strlist_chooser ; 02186 02187 } else { /************* have an old dataset *************/ 02188 02189 DSET_delete(dset) ; /* delete the new copy */ 02190 dset = old_dset ; /* instead, will replace contents of old dataset */ 02191 } 02192 02193 DSET_superlock(dset) ; /*-- make sure will not be purged from memory! --*/ 02194 02195 /* load any data bricks present in the group element */ 02196 02197 (void)THD_add_bricks( dset , ngr ) ; 02198 THD_update_statistics( dset ) ; 02199 02200 /** wrapup **/ 02201 02202 if( ct_start >= 0 ) /* keep track */ 02203 ct_tot = NI_clock_time() - ct_start ; /* of time spent */ 02204 02205 if( old_dset == NULL ) 02206 sprintf(msg,"\n+++ NOTICE: New AFNI dataset received.\n\n") ; 02207 else 02208 sprintf(msg,"\n+++ NOTICE: Replacement AFNI dataset received.\n\n") ; 02209 02210 if( ct_tot > 0 ) sprintf(msg+strlen(msg), 02211 " I/O time = %4d ms, Processing = %4d ms\n" , 02212 ct_read , ct_tot-ct_read ) ; 02213 SHOW_MESSAGE( msg ) ; 02214 UNDUMMYIZE ; 02215 EXRETURN ; 02216 } |
|
Process a '<VOLUME_DATA ...>' element to add/replace sub-bricks in an AFNI dataset already stored somewhere (identified by the idcode). ---------------------------------------------------------------------- Definition at line 2224 of file afni_niml.c. References THD_slist_find::dset, ENTRY, NI_clock_time(), NI_get_attribute(), PLUTO_dset_finder(), SHOW_MESSAGE, THD_add_bricks(), and THD_update_statistics(). Referenced by AFNI_process_NIML_data().
02225 { 02226 char *idc ; 02227 THD_slist_find find ; 02228 02229 int ct_read = 0, ct_tot = 0 ; 02230 char msg[1024] ; 02231 02232 ENTRY("process_NIML_AFNI_volumedata") ; 02233 02234 if( ct_start >= 0 ) ct_read = NI_clock_time() - ct_start ; 02235 02236 /** find out who owns this otherwise anonymous data **/ 02237 02238 idc = NI_get_attribute( nini , "domain_parent_idcode" ) ; 02239 if( idc == NULL ) idc = NI_get_attribute( nini , "AFNI_idcode" ) ; 02240 if( idc == NULL ) idc = NI_get_attribute( nini , "idcode" ) ; 02241 if( idc == NULL ){ 02242 fprintf(stderr,"\n** ERROR: anonymous VOLUME_DATA received via NIML\a\n"); 02243 EXRETURN ; 02244 } 02245 02246 find = PLUTO_dset_finder(idc) ; 02247 if( find.dset == NULL ){ 02248 fprintf(stderr,"\n** ERROR: orphan VOLUME_DATA received via NIML\a\n"); 02249 EXRETURN ; 02250 } 02251 02252 /** put this data into the dataset **/ 02253 02254 (void)THD_add_bricks( find.dset , nini ) ; 02255 THD_update_statistics( find.dset ) ; 02256 02257 /** wrapup **/ 02258 02259 if( ct_start >= 0 ) /* keep track */ 02260 ct_tot = NI_clock_time() - ct_start ; /* of time spent */ 02261 02262 sprintf(msg,"\n+++ NOTICE: Replacement AFNI sub-bricks received.\n\n") ; 02263 02264 if( ct_tot > 0 ) sprintf(msg+strlen(msg), 02265 " I/O time = %4d ms, Processing = %4d ms\n" , 02266 ct_read , ct_tot-ct_read ) ; 02267 SHOW_MESSAGE( msg ) ; 02268 EXRETURN ; 02269 } |
|
Process a '<MRI_IMAGE ...>' element to add a .1D file to AFNI's library of such things. ---------------------------------------------------------------------- Definition at line 2276 of file afni_niml.c. References AFNI_add_timeseries(), ENTRY, MRI_IMAGE::kind, mmm, mri_add_name(), mri_free(), mri_to_float(), MRI_IMAGE::name, niml_to_mri(), MRI_IMAGE::nx, MRI_IMAGE::ny, and MRI_IMAGE::nz. Referenced by AFNI_process_NIML_data().
02277 { 02278 MRI_IMAGE *im ; 02279 02280 ENTRY("process_NIML_MRI_IMAGE") ; 02281 02282 im = niml_to_mri( nel ) ; /* convert element to an image */ 02283 02284 /* reject bad or overlarge images */ 02285 02286 if( im == NULL ) EXRETURN ; 02287 if( im->nx < 2 || im->nz > 1 || im->ny > 99 ){ mri_free(im); EXRETURN; } 02288 02289 /* convert to float, if needed */ 02290 02291 if( im->kind != MRI_float ){ 02292 MRI_IMAGE *qim = mri_to_float(im) ; 02293 if( qim != NULL ){ mri_free(im); im = qim; } 02294 } 02295 02296 /* make up a name, if none provided */ 02297 02298 if( im->name == NULL || im->name[0] == '\0' ){ 02299 static int nnn=1 ; char mmm[32] ; 02300 sprintf(mmm,"niml_%03d",nnn) ; 02301 mri_add_name(mmm,im) ; 02302 } 02303 02304 /* store in AFNI's list, and vamoose */ 02305 02306 AFNI_add_timeseries( im ) ; 02307 EXRETURN ; 02308 } |
|
Definition at line 1830 of file afni_niml.c. References ADN_brick_fac, ADN_func_type, ADN_none, ADN_ntt, ADN_nvals, ADN_prefix, ADN_type, AFNI_finalize_dataset_CB(), AFNI_find_open_controller(), AFNI_popup_message(), AFNI_process_drawnotice(), AFNI_update_all_surface_widgets(), AFNI_view_info::anat_num, AFNI_viewing_widgets::choose_anat_pb, AFNI_viewing_widgets::choose_func_pb, AFNI_viewing_widgets::choose_sess_pb, THD_3dim_dataset::daxes, DESTROY_VVLIST, dont_overlay_suma, THD_slist_find::dset, DSET_BRICK_ARRAY, DSET_FILECODE, THD_slist_find::dset_index, DSET_load, DSET_LOADED, DSET_lock, DSET_mallocize, DSET_NX, DSET_NY, DSET_write, DSET_XXMAX, DSET_XXMIN, DSET_YYMAX, DSET_YYMIN, DSET_ZZMAX, DSET_ZZMIN, THD_session::dsset, EDIT_BRICK_TO_NOSTAT, EDIT_dset_items(), EDIT_empty_copy(), EDIT_substitute_brick(), ENTRY, EQUIV_DATAXES, FIND_PREFIX, FUNC_BUCK_TYPE, AFNI_view_info::func_num, AFNI_view_info::func_visible, GLOBAL_library, HEAD_FUNC_TYPE, SUMA_surface::idcode, THD_ivec3::ijk, AFNI_widget_set::imag, MCW_choose_cbs::ival, SUMA_surface::ixyz, LOAD_FVEC3, malloc, MCW_set_bbox(), NI_clock_time(), NI_get_attribute(), NI_INT, THD_session::num_dsset, SUMA_vvlist::nvox, PLUTO_dset_finder(), PLUTO_dset_redisplay(), AFNI_imaging_widgets::pop_sumato_pb, RETURN, AFNI_viewing_widgets::see_func_bbox, THD_slist_find::sess_index, AFNI_view_info::sess_num, THD_session::sessname, SHOW_MESSAGE, THD_sessionlist::ssar, AFNI_library_type::sslist, STATUS, THD_session::su_num, THD_session::su_surf, SUMA_find_node_id(), THD_3dmm_to_3dind(), THD_dicomm_to_3dmm(), THD_dset_in_session(), THD_filename_pure(), THD_MAX_SESSION_SIZE, NI_element::vec, NI_element::vec_filled, NI_element::vec_num, NI_element::vec_typ, AFNI_widget_set::view, THD_3dim_dataset::view_type, Three_D_View::vinfo, SUMA_vvlist::voxijk, SUMA_vvlist::voxval, SUMA_surface::vv, Three_D_View::vwid, THD_3dim_dataset::wod_flag, SUMA_ixyz::x, THD_fvec3::xyz, SUMA_ixyz::y, and SUMA_ixyz::z. Referenced by AFNI_process_NIML_data().
01831 { 01832 int *nlist , *nval , num_list , num,ii,jj,pp,ks ; 01833 char *surf_idc , *roi_prefix , *dset_idc ; 01834 THD_slist_find find ; 01835 THD_3dim_dataset *dset_anat , *dset_func ; 01836 SUMA_surface *ag ; 01837 Three_D_View *im3d = AFNI_find_open_controller() ; 01838 MCW_choose_cbs cbs ; 01839 THD_session *sess ; 01840 THD_fvec3 fv ; THD_ivec3 iv ; 01841 short *funcar ; 01842 float xbot,ybot,zbot , xtop,ytop,ztop ; 01843 int wodsave , nx,ny,nxy ; 01844 int ct_read = 0 ; 01845 char msg[1024] ; 01846 01847 ENTRY("process_NIML_Node_ROI"); 01848 01849 if( dont_hear_suma ) RETURN(0) ; 01850 01851 if( ct_start >= 0 ) ct_read = NI_clock_time() - ct_start ; 01852 01853 STATUS("received Node_ROI element") ; 01854 01855 if( nel->vec_num < 2 || 01856 nel->vec_typ[0] != NI_INT || 01857 nel->vec_typ[1] != NI_INT ){ 01858 01859 SHOW_MESSAGE( "+++ WARNING:\n\n" 01860 " Node_ROI input \n" 01861 " is badly formatted!\n" ); 01862 RETURN(1) ; 01863 } 01864 01865 nlist = (int *) nel->vec[0] ; /* node list */ 01866 nval = (int *) nel->vec[1] ; /* value list */ 01867 num_list = nel->vec_filled ; /* number of nodes */ 01868 01869 /** get ID codes of surface and anat parents **/ 01870 01871 STATUS("checking Node_ROI ID codes") ; 01872 01873 surf_idc = NI_get_attribute( nel , "MeshParent_idcode" ) ; 01874 if( surf_idc == NULL ) 01875 surf_idc = NI_get_attribute( nel , "surface_idcode" ) ; 01876 if( surf_idc == NULL ) 01877 surf_idc = NI_get_attribute( nel , "SUMA_idcode" ) ; 01878 01879 dset_idc = NI_get_attribute( nel , "volume_idcode" ) ; 01880 if( dset_idc == NULL ) 01881 dset_idc = NI_get_attribute( nel , "dataset_idcode" ) ; 01882 01883 /** get name of dataset this goes into **/ 01884 01885 roi_prefix = NI_get_attribute( nel , "target_volume" ) ; 01886 if( roi_prefix == NULL ) 01887 roi_prefix = NI_get_attribute( nel , "ROI_prefix" ) ; 01888 01889 /** check for errors [there are lots of possibilities] **/ 01890 01891 if( surf_idc == NULL ){ 01892 AFNI_popup_message( "*** ERROR:\n\n" 01893 " Node_ROI input doesn't\n" 01894 " set 'MeshParent_idcode'!\n" ) ; 01895 RETURN(1) ; 01896 } 01897 if( dset_idc == NULL ){ 01898 AFNI_popup_message( "*** ERROR:\n\n" 01899 " Node_ROI input doesn't\n" 01900 " set 'volume_idcode'!\n" ) ; 01901 RETURN(1) ; 01902 } 01903 if( roi_prefix == NULL ){ 01904 AFNI_popup_message( "*** ERROR:\n\n" 01905 " Node_ROI input doesn't\n" 01906 " set 'target_volume'!\n" ) ; 01907 RETURN(1) ; 01908 } 01909 if( !THD_filename_pure(roi_prefix) ){ 01910 sprintf(msg, "*** ERROR:\n\n" 01911 " Node_ROI 'target_volume' prefix \n" 01912 " %s\n" 01913 " contains illegal characters!\n" , roi_prefix ) ; 01914 AFNI_popup_message( msg ) ; 01915 RETURN(1) ; 01916 } 01917 01918 /** find parent volume for this ROI (from its ID code) **/ 01919 01920 STATUS("searching for Node_ROI parent volume") ; 01921 01922 find = PLUTO_dset_finder( dset_idc ) ; dset_anat = find.dset ; 01923 if( dset_anat == NULL ){ 01924 sprintf(msg, "*** ERROR:\n\n" 01925 " Node_ROI volume dataset idcode is \n" 01926 " %s\n" 01927 " Can't find this in AFNI\n", dset_idc ) ; 01928 AFNI_popup_message( msg ) ; 01929 RETURN(1) ; 01930 } 01931 sess = GLOBAL_library.sslist->ssar[find.sess_index] ; /* 20 Jan 2004 */ 01932 01933 /** find the surface within this session (from its ID code) **/ 01934 01935 STATUS("searching for Node_ROI surface") ; 01936 01937 num = sess->su_num ; 01938 if( num == 0 ){ 01939 sprintf(msg,"*** ERROR:\n\n" 01940 " Node_ROI data received for dataset\n" 01941 " %.222s\n" 01942 " but no surfaces available in session! \n" , 01943 DSET_FILECODE(dset_anat) ) ; 01944 AFNI_popup_message( msg ) ; 01945 RETURN(1) ; 01946 } 01947 01948 for( ks=0 ; ks < num ; ks++ ) 01949 if( strstr(sess->su_surf[ks]->idcode,surf_idc) != NULL ) break ; 01950 01951 if( ks == num ){ 01952 sprintf(msg, "*** ERROR:\n\n" 01953 " Node_ROI surface idcode\n" 01954 " %s\n" 01955 " does not match any surface in session \n" 01956 " %.222s\n" , 01957 surf_idc, sess->sessname ) ; 01958 AFNI_popup_message( msg ) ; 01959 RETURN(1) ; 01960 } 01961 01962 ag = sess->su_surf[ks] ; /* set surface to run with */ 01963 01964 /** switch session and anat dataset, if need be **/ 01965 01966 if( find.sess_index != im3d->vinfo->sess_num ){ 01967 cbs.ival = find.sess_index ; 01968 AFNI_finalize_dataset_CB( im3d->vwid->view->choose_sess_pb , 01969 (XtPointer) im3d , &cbs ) ; 01970 } 01971 if( find.dset_index >= 0 && find.dset_index != im3d->vinfo->anat_num ){ 01972 cbs.ival = find.dset_index ; 01973 AFNI_finalize_dataset_CB( im3d->vwid->view->choose_anat_pb , 01974 (XtPointer) im3d , &cbs ) ; 01975 } 01976 01977 AFNI_update_all_surface_widgets( sess ) ; 01978 #if 0 01979 XtSetSensitive( im3d->vwid->imag->pop_sumato_pb, True ) ; 01980 #endif 01981 01982 /* see if ROI dataset already exists */ 01983 01984 STATUS("searching for Node_ROI functional dataset") ; 01985 01986 find = THD_dset_in_session( FIND_PREFIX , roi_prefix , sess ) ; 01987 dset_func = find.dset ; 01988 01989 /* func dataset already exists? Check if for goodness. */ 01990 01991 if( dset_func != NULL ){ 01992 if( !EQUIV_DATAXES(dset_anat->daxes,dset_func->daxes) ){ 01993 sprintf(msg, "*** ERROR:\n\n" 01994 " Node_ROI functional dataset\n" 01995 " %.222s\n" 01996 " exists, but doesn't match geometry of anat dataset\n" 01997 " %.222s\n" , 01998 roi_prefix , DSET_FILECODE(dset_anat) ) ; 01999 AFNI_popup_message( msg ) ; 02000 RETURN(1) ; 02001 } 02002 DSET_mallocize(dset_func) ; /* oops */ 02003 if( !DSET_LOADED(dset_func) ){ 02004 DSET_load(dset_func) ; 02005 if( !DSET_LOADED(dset_func) ){ 02006 sprintf(msg, "*** ERROR:\n\n" 02007 " Node_ROI functional dataset\n" 02008 " %.222s\n" 02009 " exists, but doesn't have data!\n" , 02010 roi_prefix ) ; 02011 AFNI_popup_message( msg ) ; 02012 RETURN(1) ; 02013 } 02014 DESTROY_VVLIST(ag->vv) ; ag->vv = NULL ; 02015 sprintf(msg,"+++ NOTICE:\n\n" 02016 " Node_ROI command is using existing dataset\n" 02017 " %.222s\n" , DSET_FILECODE(dset_func) ) ; 02018 SHOW_MESSAGE( msg ) ; 02019 } 02020 if( find.dset_index >= 0 && find.dset_index != im3d->vinfo->func_num ){ 02021 cbs.ival = find.dset_index ; 02022 AFNI_finalize_dataset_CB( im3d->vwid->view->choose_func_pb , 02023 (XtPointer) im3d , &cbs ) ; 02024 } 02025 02026 } else { /*** no pre-existing func? create a dataset now ***/ 02027 02028 ii = sess->num_dsset ; 02029 if( ii >= THD_MAX_SESSION_SIZE ){ 02030 sprintf(msg, "*** ERROR:\n\n" 02031 " Can't create Node_ROI dataset\n" 02032 " %.222s\n" 02033 " because of AFNI session overflow!\n" , 02034 roi_prefix ) ; 02035 AFNI_popup_message( msg ) ; 02036 RETURN(1) ; 02037 } 02038 02039 dset_func = EDIT_empty_copy( dset_anat ) ; 02040 EDIT_dset_items( dset_func , 02041 ADN_prefix , roi_prefix , 02042 ADN_type , HEAD_FUNC_TYPE , 02043 ADN_func_type , FUNC_BUCK_TYPE , 02044 ADN_nvals , 1 , 02045 ADN_ntt , 0 , 02046 ADN_brick_fac , NULL , 02047 ADN_none ) ; 02048 EDIT_BRICK_TO_NOSTAT( dset_func , 0 ) ; 02049 EDIT_substitute_brick( dset_func , 0 , MRI_short , NULL ) ; 02050 02051 sess->dsset[ii][dset_func->view_type] = dset_func ; 02052 sess->num_dsset ++ ; 02053 02054 STATUS("switching func to Node_ROI dataset") ; 02055 02056 cbs.ival = ii ; 02057 AFNI_finalize_dataset_CB( im3d->vwid->view->choose_func_pb , 02058 (XtPointer) im3d , &cbs ) ; 02059 02060 STATUS("popping up Node_ROI dataset creation notice") ; 02061 sprintf(msg,"+++ NOTICE:\n\n" 02062 " Node_ROI command is creating dataset\n" 02063 " %.222s\n" , 02064 DSET_FILECODE(dset_func) ) ; 02065 SHOW_MESSAGE( msg ) ; 02066 02067 STATUS("destroying any pre-existing Node_ROI vvlist") ; 02068 DESTROY_VVLIST(ag->vv) ; ag->vv = NULL ; 02069 } 02070 02071 STATUS("locking Node_ROI dataset into memory") ; 02072 DSET_lock(dset_func) ; /* lock into memory (no purge allowed) */ 02073 02074 funcar = (short *) DSET_BRICK_ARRAY(dset_func,0) ; /* array to draw */ 02075 02076 /** now, see if there is an old voxel value list 02077 attached to the surface ; if so zero out those voxels **/ 02078 02079 if( ag->vv != NULL ){ 02080 fprintf(stderr,"++ erasing %d voxels from previous SUMA ROI\n",ag->vv->nvox) ; 02081 for( ii=0 ; ii < ag->vv->nvox ; ii++ ) funcar[ ag->vv->voxijk[ii] ] = 0; 02082 DESTROY_VVLIST(ag->vv) ; ag->vv = NULL ; 02083 } else { 02084 STATUS("no old Node_ROI vvlist") ; 02085 } 02086 02087 /** now put values from SUMA into dataset array **/ 02088 02089 if( num_list > 0 ){ 02090 fprintf(stderr,"++ writing %d voxels from SUMA ROI\n",num_list) ; 02091 ag->vv = (SUMA_vvlist *) malloc( sizeof(SUMA_vvlist) ) ; 02092 ag->vv->nvox = num_list ; 02093 ag->vv->voxijk = (int *) malloc( sizeof(int) *num_list ) ; 02094 ag->vv->voxval = (float *) malloc( sizeof(float)*num_list ) ; 02095 02096 wodsave = dset_func->wod_flag ; dset_func->wod_flag = 0 ; 02097 02098 xbot = DSET_XXMIN(dset_func) ; xtop = DSET_XXMAX(dset_func) ; 02099 ybot = DSET_YYMIN(dset_func) ; ytop = DSET_YYMAX(dset_func) ; 02100 zbot = DSET_ZZMIN(dset_func) ; ztop = DSET_ZZMAX(dset_func) ; 02101 nx = DSET_NX(dset_func); ny = DSET_NY(dset_func); nxy = nx*ny ; 02102 02103 for( ii=0 ; ii < num_list ; ii++ ){ 02104 pp = SUMA_find_node_id( ag , nlist[ii] ) ; 02105 if( pp >= 0 ){ 02106 LOAD_FVEC3( fv , ag->ixyz[pp].x, ag->ixyz[pp].y, ag->ixyz[pp].z ) ; 02107 fv = THD_dicomm_to_3dmm( dset_func , fv ) ; 02108 if( fv.xyz[0] < xbot || fv.xyz[0] > xtop ) continue ; 02109 if( fv.xyz[1] < ybot || fv.xyz[1] > ytop ) continue ; 02110 if( fv.xyz[2] < zbot || fv.xyz[2] > ztop ) continue ; 02111 iv = THD_3dmm_to_3dind( dset_func , fv ) ; 02112 jj = iv.ijk[0] + iv.ijk[1]*nx + iv.ijk[2]*nxy ; 02113 funcar[jj] = nval[ii] ; 02114 ag->vv->voxijk[ii] = jj ; ag->vv->voxval[ii] = nval[ii] ; 02115 } 02116 } 02117 } else { 02118 STATUS("no nodes in Node_ROI input") ; 02119 } 02120 02121 DSET_write( dset_func ) ; /* save to disk */ 02122 02123 dont_overlay_suma = 1 ; 02124 02125 STATUS("redisplay Node_ROI function") ; 02126 MCW_set_bbox( im3d->vwid->view->see_func_bbox , 1 ) ; 02127 im3d->vinfo->func_visible = 1 ; 02128 PLUTO_dset_redisplay( dset_func ) ; /* redisplay windows with this dataset */ 02129 AFNI_process_drawnotice( im3d ) ; 02130 02131 RETURN(0) ; 02132 } |
|
Definition at line 1802 of file afni_niml.c. References AFNI_find_open_controller(), AFNI_jumpto_dicom(), dont_tell_suma, ENTRY, NI_FLOAT, RETURN, SHOW_MESSAGE, NI_element::vec, NI_element::vec_filled, NI_element::vec_len, NI_element::vec_num, and NI_element::vec_typ. Referenced by AFNI_process_NIML_data().
01803 { 01804 float *xyz ; 01805 01806 ENTRY("process_NIML_SUMA_crosshair_xyz"); 01807 01808 if( dont_hear_suma ) RETURN(0) ; 01809 01810 if( nel->vec_len < 3 || 01811 nel->vec_filled < 3 || 01812 nel->vec_num < 1 || 01813 nel->vec_typ[0] != NI_FLOAT ){ 01814 01815 SHOW_MESSAGE( "+++ WARNING:\n\n" 01816 " SUMA_crosshair_xyz input \n" 01817 " is badly formatted!\n" ); 01818 RETURN(1) ; 01819 } 01820 01821 xyz = (float *) nel->vec[0] ; 01822 dont_tell_suma = 1 ; 01823 AFNI_jumpto_dicom( AFNI_find_open_controller(), xyz[0],xyz[1],xyz[2] ); 01824 dont_tell_suma = 0 ; 01825 RETURN(0) ; 01826 } |
|
Definition at line 1492 of file afni_niml.c. References AFNI_popup_message(), dont_tell_suma, THD_slist_find::dset, DSET_FILECODE, ENTRY, GLOBAL_library, SUMA_surface::idcode, SUMA_surface::label, NI_clock_time(), NI_get_attribute(), NI_INT, SUMA_surface::num_ijk, PLUTO_dset_finder(), PLUTO_dset_redisplay(), RETURN, THD_slist_find::sess_index, THD_session::sessname, SHOW_MESSAGE, THD_sessionlist::ssar, AFNI_library_type::sslist, THD_session::su_num, THD_session::su_surf, SUMA_add_triangles(), NI_element::vec, NI_element::vec_filled, NI_element::vec_len, NI_element::vec_num, and NI_element::vec_typ. Referenced by AFNI_process_NIML_data().
01493 { 01494 THD_3dim_dataset *dset ; 01495 SUMA_surface *ag ; 01496 int *it, *jt , *kt ; char *idc ; 01497 int num , surf_num , nold ; 01498 THD_session *sess ; /* 20 Jan 2004 */ 01499 THD_slist_find find ; 01500 int ct_read = 0, ct_tot = 0 ; 01501 char msg[1024] ; 01502 01503 ENTRY("process_NIML_SUMA_ijk"); 01504 01505 if( dont_hear_suma ) RETURN(0) ; 01506 01507 if( ct_start >= 0 ) ct_read = NI_clock_time() - ct_start ; 01508 01509 /*-- check element for suitability --*/ 01510 01511 if( nel->vec_len < 1 || /* empty element? */ 01512 nel->vec_filled < 1 || /* no data was filled in? */ 01513 nel->vec_num < 3 || /* less than 4 columns? */ 01514 nel->vec_typ[0] != NI_INT || /* must be int,int,int */ 01515 nel->vec_typ[1] != NI_INT || 01516 nel->vec_typ[2] != NI_INT ){ 01517 01518 AFNI_popup_message( "*** ERROR:\n\n" 01519 " SUMA_ijk surface data \n" 01520 " is badly formatted!\n" ) ; 01521 RETURN(1) ; 01522 } 01523 01524 /*-- we need a "volume_idcode" or "dataset_idcode" attribute, 01525 so that we can attach this surface to a dataset for display; 01526 if we don't find the attribute or the dataset, then we quit --*/ 01527 01528 idc = NI_get_attribute( nel , "volume_idcode" ) ; 01529 if( idc == NULL ) 01530 idc = NI_get_attribute( nel , "dataset_idcode" ) ; 01531 if( idc == NULL ){ 01532 AFNI_popup_message( "*** ERROR:\n " 01533 " SUMA_ijk surface input\n" 01534 " does not identify dataset! \n" ) ; 01535 RETURN(1) ; 01536 } 01537 find = PLUTO_dset_finder( idc ) ; dset = find.dset ; 01538 if( dset == NULL ){ 01539 sprintf(msg, "*** ERROR:\n\n" 01540 " SUMA_ijk surface dataset idcode is \n" 01541 " %s\n" 01542 " Can't find this in AFNI\n", idc ) ; 01543 AFNI_popup_message( msg ) ; 01544 RETURN(1) ; 01545 } 01546 sess = GLOBAL_library.sslist->ssar[find.sess_index] ; /* 20 Jan 2004 */ 01547 01548 /*-- session must already have a surface --*/ 01549 01550 num = sess->su_num ; 01551 if( num == 0 ){ 01552 sprintf(msg,"*** ERROR:\n\n" 01553 " SUMA_ijk surface data\n" 01554 " received for dataset\n" 01555 " %.222s\n" 01556 " before any SUMA_ixyz data! \n" , 01557 DSET_FILECODE(dset) ) ; 01558 AFNI_popup_message( msg ) ; 01559 RETURN(1) ; 01560 } 01561 01562 idc = NI_get_attribute( nel , "surface_idcode" ) ; 01563 if( idc == NULL ) 01564 idc = NI_get_attribute( nel , "SUMA_idcode" ) ; 01565 if( idc == NULL ){ 01566 AFNI_popup_message( "*** ERROR:\n\n" 01567 " SUMA_ijk surface input\n" 01568 " does not have surface idcode! \n" ) ; 01569 RETURN(1) ; 01570 } 01571 01572 /* 14 Aug 2002: find surface idcode in dataset's list of surfaces */ 01573 01574 for( surf_num=0 ; surf_num < num ; surf_num++ ) 01575 if( strstr(sess->su_surf[surf_num]->idcode,idc) != NULL ) break ; 01576 01577 if( surf_num == num ){ 01578 sprintf(msg, "*** ERROR:\n\n" 01579 " SUMA_ijk surface input surface idcode\n" 01580 " %s\n" 01581 " does not match any surface in session \n" 01582 " %.222s\n" , 01583 idc, sess->sessname ) ; 01584 AFNI_popup_message( msg ) ; 01585 RETURN(1) ; 01586 } 01587 01588 ag = sess->su_surf[surf_num] ; /* set surface to run with */ 01589 01590 if( ag->num_ijk > 0 ){ 01591 sprintf(msg, "*** WARNING:\n\n" 01592 " SUMA_ijk surface input surface idcode\n" 01593 " %s\n" 01594 " already has %d triangles in it, and\n" 01595 " the SUMA user is trying to add %d more!\n" , 01596 idc, ag->num_ijk , nel->vec_filled ) ; 01597 AFNI_popup_message( msg ) ; 01598 RETURN(1) ; /* perhaps we can remove this */ 01599 } 01600 01601 /*-- pointers to the data columns in the NI_element --*/ 01602 01603 it = (int *) nel->vec[0] ; /* node index #1 */ 01604 jt = (int *) nel->vec[1] ; /* node index #2 */ 01605 kt = (int *) nel->vec[2] ; /* node index #3 */ 01606 01607 /*-- add nodes to the surface --*/ 01608 01609 nold = ag->num_ijk ; /* 19 Aug 2002: # triangles before */ 01610 01611 SUMA_add_triangles( ag , nel->vec_filled , it,jt,kt ) ; 01612 01613 /*-- we're done! --*/ 01614 01615 if( ct_start >= 0 ) /* keep track */ 01616 ct_tot = NI_clock_time() - ct_start ; /* of time spent */ 01617 01618 /* let the pitiful user see what just happened */ 01619 if( nold == 0 ) 01620 sprintf(msg,"\n+++ NOTICE: SUMA_ijk: %d triangles attached\n" 01621 " to surface %-14.14s (#%d),\n" 01622 " session %.222s\n" , 01623 nel->vec_filled, ag->label, surf_num, sess->sessname ) ; 01624 else 01625 sprintf(msg,"\n+++ NOTICE: SUMA_ijk: %d triangles ADDED\n" 01626 " (was %d) to surface %-14.14s (#%d),\n" 01627 " session %.222s\n" , 01628 nel->vec_filled, nold, ag->label, surf_num, sess->sessname ) ; 01629 01630 if( ct_tot > 0 ) sprintf(msg+strlen(msg), 01631 " I/O time = %4d ms, Processing = %4d ms\n" , 01632 ct_read , ct_tot-ct_read ) ; 01633 01634 SHOW_MESSAGE(msg) ; 01635 01636 dont_tell_suma = 1 ; 01637 PLUTO_dset_redisplay( dset ) ; /* redisplay windows with this dataset */ 01638 dont_tell_suma = 0 ; 01639 01640 RETURN(0) ; 01641 } |
|
Definition at line 1259 of file afni_niml.c. References AFNI_finalize_dataset_CB(), AFNI_find_open_controller(), AFNI_popup_message(), AFNI_update_all_surface_widgets(), AFNI_view_info::anat_num, AFNI_viewing_widgets::choose_anat_pb, AFNI_viewing_widgets::choose_sess_pb, dont_tell_suma, THD_slist_find::dset, THD_slist_find::dset_index, ENTRY, GLOBAL_library, THD_3dim_dataset::idcode, SUMA_surface::idcode, SUMA_surface::idcode_dset, SUMA_surface::idcode_ldp, SUMA_surface::ijk, AFNI_widget_set::imag, MCW_choose_cbs::ival, SUMA_surface::label, SUMA_surface::label_ldp, MCW_strncpy, SUMA_surface::nall_ijk, NI_clock_time(), NI_FLOAT, NI_get_attribute(), NI_INT, SUMA_surface::num_ijk, SUMA_surface::num_ixyz, THD_sessionlist::num_sess, PLUTO_dset_finder(), PLUTO_dset_redisplay(), AFNI_imaging_widgets::pop_sumato_pb, realloc, RETURN, THD_slist_find::sess_index, AFNI_view_info::sess_num, THD_session::sessname, SHOW_MESSAGE, THD_sessionlist::ssar, AFNI_library_type::sslist, MCW_idcode::str, THD_session::su_num, THD_session::su_surf, SUMA_add_nodes_ixyz(), SUMA_create_empty_surface(), SUMA_destroy_surface(), SUMA_ixyzsort_surface(), UNIQ_idcode_fill(), NI_element::vec, NI_element::vec_filled, NI_element::vec_len, NI_element::vec_num, NI_element::vec_typ, AFNI_widget_set::view, Three_D_View::vinfo, Three_D_View::vwid, xc, and yc. Referenced by AFNI_process_NIML_data().
01260 { 01261 THD_slist_find find ; 01262 THD_3dim_dataset *dset ; 01263 THD_session *sess ; /* 20 Jan 2004 */ 01264 SUMA_surface *ag, *sold; 01265 int *ic ; float *xc,*yc,*zc ; char *idc , idstr[32] ; 01266 int num , surf_num , replace ; 01267 Three_D_View *im3d = AFNI_find_open_controller() ; 01268 MCW_choose_cbs cbs ; 01269 int nss = GLOBAL_library.sslist->num_sess ; 01270 int ct_read = 0, ct_tot = 0 ; 01271 char msg[1024] ; 01272 01273 ENTRY("process_NIML_SUMA_ixyz"); 01274 01275 if( dont_hear_suma ) RETURN(0) ; 01276 01277 if( ct_start >= 0 ) ct_read = NI_clock_time() - ct_start ; 01278 01279 /*-- check element for suitability --*/ 01280 01281 if( nel->vec_len < 1 || /* empty element? */ 01282 nel->vec_filled < 1 || /* no data was filled in? */ 01283 nel->vec_num < 4 || /* less than 4 columns? */ 01284 nel->vec_typ[0] != NI_INT || /* must be int,float,float,float */ 01285 nel->vec_typ[1] != NI_FLOAT || 01286 nel->vec_typ[2] != NI_FLOAT || 01287 nel->vec_typ[3] != NI_FLOAT ){ 01288 01289 AFNI_popup_message( "*** ERROR:\n\n" 01290 " SUMA_ixyz surface data\n" 01291 " is badly formatted! \n" ) ; 01292 01293 if( nel->vec_len < 1 ) 01294 fprintf(stderr,"** SUMA_ixyz vec_len = %d\n",nel->vec_len) ; 01295 if( nel->vec_filled < 1 ) 01296 fprintf(stderr,"** SUMA_ixyz vec_filled = %d\n",nel->vec_filled) ; 01297 RETURN(1) ; 01298 } 01299 01300 /*-- we need a "volume_idcode" or "dataset_idcode" attribute, 01301 so that we can attach this surface to a dataset for display; 01302 if we don't find the attribute or the dataset, then we quit --*/ 01303 01304 idc = NI_get_attribute( nel , "volume_idcode" ) ; 01305 if( idc == NULL ) 01306 idc = NI_get_attribute( nel , "dataset_idcode" ) ; 01307 if( idc == NULL && nss > 1 ){ 01308 AFNI_popup_message( "*** ERROR:\n " 01309 " SUMA_ixyz surface input\n" 01310 " does not identify dataset! \n " ) ; 01311 RETURN(1) ; 01312 } 01313 find = PLUTO_dset_finder(idc) ; dset = find.dset ; 01314 if( dset == NULL && nss > 1 ){ 01315 sprintf(msg, "*** ERROR:\n\n" 01316 " SUMA_ixyz volume dataset idcode is \n" 01317 " %s\n" 01318 " Can't find this in AFNI\n", idc ) ; 01319 AFNI_popup_message( msg ) ; 01320 RETURN(1) ; 01321 } 01322 01323 if( dset != NULL ) 01324 sess = GLOBAL_library.sslist->ssar[find.sess_index] ; /* 20 Jan 2004 */ 01325 else 01326 sess = GLOBAL_library.sslist->ssar[0] ; 01327 01328 /*-- get surface ID code (or make it up) --*/ 01329 01330 idc = NI_get_attribute( nel , "surface_idcode" ) ; 01331 if( idc == NULL ) 01332 idc = NI_get_attribute( nel , "SUMA_idcode" ) ; 01333 if( idc == NULL ){ 01334 UNIQ_idcode_fill(idstr) ; idc = idstr ; 01335 } 01336 01337 /*-- 14 Aug 2002: we used to trash old surfaces, 01338 but now we just accumulate them 01339 20 Jan 2004: now we put them on the session instead of dataset --*/ 01340 01341 num = sess->su_num ; /* number of surfaces currently attached */ 01342 01343 /* 19 Aug 2002: check for surface idcode in existing set of surfaces */ 01344 01345 for( surf_num=0 ; surf_num < num ; surf_num++ ) 01346 if( strstr(sess->su_surf[surf_num]->idcode,idc) != NULL ) break ; 01347 01348 /*-- 04 Jan 2005 [rickr]: allow surface replacement, check num_ixyz 01349 for decision on whether to keep triangles --*/ 01350 if( surf_num < num ){ 01351 replace = 1 ; /* this surface exists, replace it */ 01352 } else { 01353 replace = 0 ; 01354 num++ ; /* note that there is one more surface now */ 01355 01356 /*-- make space for 1 more set of surface pointers --*/ 01357 sess->su_surf = (SUMA_surface **) realloc(sess->su_surf, 01358 num*sizeof(SUMA_surface *)) ; 01359 } 01360 /* note: surf_num is the appropriate index for the received surface */ 01361 01362 /*-- initialize surface that we will fill up here --*/ 01363 01364 ag = SUMA_create_empty_surface() ; 01365 01366 MCW_strncpy(ag->idcode,idc,32); /* idc is surface idcode from above */ 01367 01368 /*-- 06 Oct 2004 [rickr]: get idcode of local domain parent (to surface) --*/ 01369 01370 idc = NI_get_attribute( nel , "local_domain_parent_ID" ) ; 01371 if( idc == NULL ){ 01372 UNIQ_idcode_fill(idstr) ; idc = idstr ; 01373 } 01374 MCW_strncpy(ag->idcode_ldp,idc,32) ; 01375 01376 /*-- 19 Aug 2002: get surface label (or make it up) --*/ 01377 01378 idc = NI_get_attribute( nel , "surface_label" ) ; 01379 if( idc == NULL ) 01380 idc = NI_get_attribute( nel , "SUMA_label" ) ; 01381 01382 if( idc != NULL ) 01383 MCW_strncpy(ag->label,idc,64) ; 01384 else 01385 sprintf(ag->label,"Surf#%d",num) ; 01386 01387 /*-- 06 Oct 2004: get label of local domain parent (or make it up) --*/ 01388 01389 idc = NI_get_attribute( nel , "local_domain_parent" ) ; 01390 if( idc == NULL ) 01391 sprintf(ag->label_ldp,"Surf#%d_local_domain_parent",num) ; 01392 else 01393 MCW_strncpy(ag->label_ldp,idc,64) ; 01394 01395 /*-- set IDCODEs of surface and of its dataset --*/ 01396 01397 if( dset != NULL ) 01398 MCW_strncpy( ag->idcode_dset , dset->idcode.str , 32 ) ; 01399 01400 /*-- pointers to the data columns in the NI_element --*/ 01401 01402 ic = (int *) nel->vec[0] ; /* index */ 01403 xc = (float *) nel->vec[1] ; /* x coordinate */ 01404 yc = (float *) nel->vec[2] ; /* y coordinate */ 01405 zc = (float *) nel->vec[3] ; /* z coordinate */ 01406 01407 /*-- add nodes to the surface --*/ 01408 01409 SUMA_add_nodes_ixyz( ag , nel->vec_filled , ic,xc,yc,zc ) ; 01410 01411 /*-- prepare the surface for AFNI --*/ 01412 01413 SUMA_ixyzsort_surface( ag ) ; 01414 01415 sess->su_num = num ; /* 14 Aug 2002 (may be same value) */ 01416 01417 /* 04 Jan 2005 [rickr]: if we are replacing the old surface, do it now */ 01418 01419 sold = sess->su_surf[surf_num] ; /* store the old pointer, in case */ 01420 sess->su_surf[surf_num] = ag ; /* set the new pointer, either way */ 01421 01422 if( replace ){ 01423 if( sold->num_ixyz == ag->num_ixyz ){ 01424 /* same number of nodes, move the triangle information */ 01425 ag->num_ijk = sold->num_ijk ; sold->num_ijk = 0 ; 01426 ag->nall_ijk = sold->nall_ijk ; sold->nall_ijk = 0 ; 01427 ag->ijk = sold->ijk ; sold->ijk = NULL ; 01428 } else { /* the number of nodes has changed */ 01429 sprintf(msg,"+++ NOTICE:\n" 01430 " Surface '%-14.14s' (#%d) for\n" 01431 " session '%.222s'\n" 01432 " went from %d nodes to %d nodes\n" , 01433 ag->label, surf_num, sess->sessname, 01434 sold->num_ixyz , ag->num_ixyz) ; 01435 AFNI_popup_message( msg ) ; /* include this in clock time */ 01436 } 01437 /* and finally, delete the old surface */ 01438 SUMA_destroy_surface( sold ) ; 01439 } 01440 01441 /*-- we're done! --*/ 01442 01443 if( ct_start >= 0 ) /* keep track of how */ 01444 ct_tot = NI_clock_time() - ct_start ; /* long this took */ 01445 01446 /* notify the user */ 01447 sprintf(msg,"\n+++ NOTICE: SUMA_ixyz: %s %d nodes\n" 01448 " for surface %-14.14s (#%d),\n" 01449 " session %.222s\n" , 01450 replace ? "replaced" : "received", 01451 nel->vec_filled, ag->label, surf_num, sess->sessname ) ; 01452 01453 if( ct_tot > 0 ) 01454 sprintf(msg+strlen(msg), 01455 " I/O time = %4d ms, Processing = %4d ms\n" , 01456 ct_read , ct_tot-ct_read ) ; 01457 01458 /* 16 Jun 2003: if need be, switch sessions and anatomy */ 01459 01460 if( dset != NULL && find.sess_index != im3d->vinfo->sess_num ){ 01461 cbs.ival = find.sess_index ; 01462 AFNI_finalize_dataset_CB( im3d->vwid->view->choose_sess_pb , 01463 (XtPointer) im3d , &cbs ) ; 01464 } 01465 #if 1 01466 if( dset != NULL && find.dset_index != im3d->vinfo->anat_num ){ 01467 cbs.ival = find.dset_index ; 01468 AFNI_finalize_dataset_CB( im3d->vwid->view->choose_anat_pb , 01469 (XtPointer) im3d , &cbs ) ; 01470 } 01471 #endif 01472 01473 SHOW_MESSAGE(msg) ; 01474 01475 /* need to make the "Control Surface" 01476 widgets know about this extra surface */ 01477 01478 AFNI_update_all_surface_widgets( sess ) ; /* 19 Aug 2002 */ 01479 01480 dont_tell_suma = 1 ; 01481 PLUTO_dset_redisplay( dset ) ; /* redisplay windows with this dataset */ 01482 dont_tell_suma = 0 ; 01483 01484 #if 0 01485 XtSetSensitive( im3d->vwid->imag->pop_sumato_pb, True ) ; 01486 #endif 01487 RETURN(0) ; 01488 } |
|
Definition at line 1645 of file afni_niml.c. References AFNI_popup_message(), dont_tell_suma, THD_slist_find::dset, DSET_FILECODE, ENTRY, GLOBAL_library, SUMA_surface::idcode, SUMA_surface::label, NI_clock_time(), NI_FLOAT, NI_get_attribute(), SUMA_surface::norm, SUMA_surface::num_ixyz, PLUTO_dset_finder(), PLUTO_dset_redisplay(), RETURN, THD_slist_find::sess_index, THD_session::sessname, SHOW_MESSAGE, THD_sessionlist::ssar, AFNI_library_type::sslist, THD_session::su_num, THD_session::su_surf, SUMA_add_norms_xyz(), NI_element::vec, NI_element::vec_filled, NI_element::vec_len, NI_element::vec_num, NI_element::vec_typ, xc, and yc. Referenced by AFNI_process_NIML_data().
01646 { 01647 THD_3dim_dataset *dset ; 01648 SUMA_surface *ag ; 01649 float *xc, *yc, *zc ; 01650 char *idc ; 01651 int num , surf_num ; 01652 THD_session *sess ; 01653 THD_slist_find find ; 01654 int ct_read = 0, ct_tot = 0 ; 01655 char msg[1024] ; 01656 01657 ENTRY("process_NIML_SUMA_node_normals"); 01658 01659 if( dont_hear_suma ) RETURN(0) ; 01660 01661 if( ct_start >= 0 ) ct_read = NI_clock_time() - ct_start ; 01662 01663 /*-- check element for suitability --*/ 01664 01665 if( nel->vec_len < 1 || /* empty element? */ 01666 nel->vec_filled < 1 || /* no data was filled in? */ 01667 nel->vec_num < 3 || /* less than 3 columns? */ 01668 nel->vec_typ[0] != NI_FLOAT || /* must be float,float,float */ 01669 nel->vec_typ[1] != NI_FLOAT || 01670 nel->vec_typ[2] != NI_FLOAT ){ 01671 01672 AFNI_popup_message( "*** ERROR:\n\n" 01673 " SUMA_node_normals data \n" 01674 " is badly formatted!\n" ) ; 01675 RETURN(1) ; 01676 } 01677 01678 /*-- we need a "volume_idcode" or "dataset_idcode" attribute, 01679 so that we can attach this surface to a dataset for display; 01680 if we don't find the attribute or the dataset, then we quit --*/ 01681 01682 idc = NI_get_attribute( nel , "volume_idcode" ) ; 01683 if( idc == NULL ) 01684 idc = NI_get_attribute( nel , "dataset_idcode" ) ; 01685 if( idc == NULL ){ 01686 AFNI_popup_message( "*** ERROR:\n " 01687 " SUMA_node_normals input\n" 01688 " does not identify dataset! \n" ) ; 01689 RETURN(1) ; 01690 } 01691 find = PLUTO_dset_finder( idc ) ; dset = find.dset ; 01692 if( dset == NULL ){ 01693 sprintf(msg, "*** ERROR:\n\n" 01694 " SUMA_node_normals surface dataset idcode is \n" 01695 " %s\n" 01696 " Can't find this in AFNI\n", idc ) ; 01697 AFNI_popup_message( msg ) ; 01698 RETURN(1) ; 01699 } 01700 sess = GLOBAL_library.sslist->ssar[find.sess_index] ; 01701 01702 /*-- session must already have a surface --*/ 01703 01704 num = sess->su_num ; 01705 if( num == 0 ){ 01706 sprintf(msg,"*** ERROR:\n\n" 01707 " SUMA_node_normals surface data\n" 01708 " received for dataset\n" 01709 " %.222s\n" 01710 " before any SUMA_ixyz data! \n" , 01711 DSET_FILECODE(dset) ) ; 01712 AFNI_popup_message( msg ) ; 01713 RETURN(1) ; 01714 } 01715 01716 idc = NI_get_attribute( nel , "surface_idcode" ) ; 01717 if( idc == NULL ) 01718 idc = NI_get_attribute( nel , "SUMA_idcode" ) ; 01719 if( idc == NULL ){ 01720 AFNI_popup_message( "*** ERROR:\n\n" 01721 " SUMA_node_normals surface input\n" 01722 " does not have surface idcode! \n" ) ; 01723 RETURN(1) ; 01724 } 01725 01726 /* find surface idcode in dataset's list of surfaces */ 01727 01728 for( surf_num=0 ; surf_num < num ; surf_num++ ) 01729 if( strstr(sess->su_surf[surf_num]->idcode,idc) != NULL ) break ; 01730 01731 if( surf_num == num ){ 01732 sprintf(msg, "*** ERROR:\n\n" 01733 " SUMA_node_normals surface input surface idcode\n" 01734 " %s\n" 01735 " does not match any surface in session \n" 01736 " %.222s\n" , 01737 idc, sess->sessname ) ; 01738 AFNI_popup_message( msg ) ; 01739 RETURN(1) ; 01740 } 01741 01742 ag = sess->su_surf[surf_num] ; /* set surface to run with */ 01743 01744 if( nel->vec_filled != ag->num_ixyz ){ 01745 sprintf(msg, "*** ERROR:\n\n" 01746 " SUMA_node_normals surface input surface idcode\n" 01747 " %s\n" 01748 " has %d nodes, but has been sent %d normals\n" , 01749 idc, ag->num_ixyz, nel->vec_filled ) ; 01750 AFNI_popup_message( msg ) ; 01751 RETURN(1) ; 01752 } 01753 01754 if( ag->norm != NULL ){ 01755 sprintf(msg, "*** WARNING:\n\n" 01756 " SUMA_node_normals surface input surface idcode\n" 01757 " %s\n" 01758 " already has normals associated with it,\n" 01759 " replacing old normals with new ones\n" , idc ) ; 01760 AFNI_popup_message( msg ) ; 01761 } 01762 01763 /*-- pointers to the data columns in the NI_element --*/ 01764 01765 xc = (float *) nel->vec[0] ; /* norm.x */ 01766 yc = (float *) nel->vec[1] ; /* norm.y */ 01767 zc = (float *) nel->vec[2] ; /* norm.z */ 01768 01769 /*-- add normals to the surface --*/ 01770 01771 if( SUMA_add_norms_xyz( ag , nel->vec_filled , xc,yc,zc ) ){ 01772 sprintf(msg, "*** ERROR:SUMA_add_norms_ixyz failure!\n"); 01773 AFNI_popup_message( msg ) ; 01774 RETURN(1) ; 01775 } 01776 01777 /*-- we're done! --*/ 01778 01779 if( ct_start >= 0 ) /* keep track */ 01780 ct_tot = NI_clock_time() - ct_start ; /* of time spent */ 01781 01782 sprintf(msg,"\n+++ NOTICE: %d normals attached\n" 01783 " to surface %-14.14s (#%d),\n" 01784 " session %.222s\n" , 01785 nel->vec_filled , ag->label , surf_num , sess->sessname ) ; 01786 01787 if( ct_tot > 0 ) sprintf(msg+strlen(msg), 01788 " I/O time = %4d ms, Processing = %4d ms\n" , 01789 ct_read , ct_tot-ct_read ) ; 01790 01791 SHOW_MESSAGE(msg) ; 01792 01793 dont_tell_suma = 1 ; 01794 PLUTO_dset_redisplay( dset ) ; /* redisplay windows with this dataset */ 01795 dont_tell_suma = 0 ; 01796 01797 RETURN(0) ; 01798 } |
|
sort slist (and sa,sb) by user selections 21 Oct 2004 [rickr] Definition at line 928 of file afni_niml.c. References v2s_opts_t::debug, ENTRY, int_list_posn(), ldp_surf_list::label_ldp, ldp_surf_list::nsurf, v2s_plugin_opts::ready, RETURN, v2s_plugin_opts::s0A, v2s_plugin_opts::s0B, v2s_plugin_opts::s1A, v2s_plugin_opts::s1B, ldp_surf_list::sA, ldp_surf_list::sB, v2s_plugin_opts::sopt, v2s_plugin_opts::use0, v2s_plugin_opts::use1, and ldp_surf_list::use_v2s. Referenced by slist_choose_surfs().
00930 { 00931 int done = 0, posn; 00932 ENTRY("slist_check_user_surfs"); 00933 00934 /* the easiest check */ 00935 if ( ! po->ready ) RETURN(0); 00936 if ( ! po->use0 && ! po->use1 ) RETURN(0); 00937 00938 if ( po->use0 ) { 00939 posn = int_list_posn(surfs, lsurf->nsurf, po->s0A); 00940 if ( posn >= 0 ) { 00941 done = 1; 00942 lsurf->use_v2s = 1; /* ready for v2s */ 00943 if ( posn != 0 ) { /* swap and set sA */ 00944 lsurf->sA = surfs[posn]; 00945 surfs[posn] = surfs[0]; 00946 surfs[0] = lsurf->sA; 00947 } 00948 00949 /* check for surfB, but skip the first position (avoid duplicate) */ 00950 if ( po->s0B < 0 ) 00951 lsurf->sB = -1; 00952 else { 00953 posn = int_list_posn(surfs+1, lsurf->nsurf-1, po->s0B) + 1; 00954 if ( posn >= 1 ) { /* we've added 1 */ 00955 if ( posn != 1 ) { /* swap and set sB */ 00956 lsurf->sB = surfs[posn]; 00957 surfs[posn] = surfs[1]; 00958 surfs[1] = lsurf->sB; 00959 } 00960 } else /* complain, and just use sB as is */ 00961 fprintf(stderr,"** user requested surf pair (%d,%d), but\n" 00962 " cannot find surf %d for LDP '%s'\n" 00963 " --> giving up and using pair (%d,%d)\n", 00964 po->s0A, po->s0B, po->s0B, lsurf->label_ldp, 00965 lsurf->sA, lsurf->sB); 00966 } 00967 } 00968 } 00969 00970 /* if we did not apply pair 0, check pair 1 */ 00971 if ( ! done && po->use1 ) { 00972 posn = int_list_posn(surfs, lsurf->nsurf, po->s1A); 00973 if ( posn >= 0 ) { 00974 done = 1; 00975 lsurf->use_v2s = 1; /* ready for v2s */ 00976 if ( posn != 0 ) { /* swap and set sA */ 00977 lsurf->sA = surfs[posn]; 00978 surfs[posn] = surfs[0]; 00979 surfs[0] = lsurf->sA; 00980 } 00981 00982 /* check for surfB, but skip the first position (avoid duplicate) */ 00983 if ( po->s1B < 0 ) 00984 lsurf->sB = -1; 00985 else { 00986 posn = int_list_posn(surfs+1, lsurf->nsurf-1, po->s1B) + 1; 00987 if ( posn >= 1 ) { 00988 if ( posn != 1 ) { /* swap and set sB */ 00989 lsurf->sB = surfs[posn]; 00990 surfs[posn] = surfs[1]; 00991 surfs[1] = lsurf->sB; 00992 } 00993 } else /* complain, and just use sB as is */ 00994 fprintf(stderr,"** user requested surf pair (%d,%d), but\n" 00995 " cannot find surf %d for LDP '%s'\n" 00996 " --> giving up and using pair (%d,%d)\n", 00997 po->s1A, po->s1B, po->s1B, lsurf->label_ldp, 00998 lsurf->sA, lsurf->sB); 00999 } 01000 } 01001 } 01002 01003 if ( po->sopt.debug > 1 ) { 01004 if ( done ) 01005 fprintf(stderr,"+d user surfs (sA,sB) = (%d,%d) {of %d}, LDP '%s'\n", 01006 lsurf->sA, lsurf->sB, lsurf->nsurf, lsurf->label_ldp); 01007 else 01008 fprintf(stderr,"+d default (sA,sB) = (%d,%d) {of %d}, LDP '%s'\n", 01009 lsurf->sA, lsurf->sB, lsurf->nsurf, lsurf->label_ldp); 01010 } 01011 01012 RETURN(0); 01013 } |
|
Now there are 2 things to clear up for each LDP (when there is more than 1 surface). If the user has selected any surfaces for v2s, then set sA and sB appropriately (and do some error checking). Also, any time there are more surfaces than needed, inform the user which will be used, and which will be ignored. Definition at line 869 of file afni_niml.c. References v2s_opts_t::debug, ENTRY, free, ldp_surf_list::full_label_ldp, SUMA_surface::label, ldp_surf_list::label_ldp, LDP_list::list, malloc, ldp_surf_list::nsurf, LDP_list::nused, RETURN, ldp_surf_list::sB, slist_check_user_surfs(), slist_surfs_for_ldp(), v2s_plugin_opts::sopt, THD_session::su_surf, and ldp_surf_list::use_v2s. Referenced by fill_ldp_surf_list().
00871 { 00872 ldp_surf_list * lsurf; 00873 int * surfs, max_surf, ldp; 00874 int first, surf; 00875 00876 ENTRY("slist_choose_surfs"); 00877 00878 /* first, decide on how much memory we need for surfs */ 00879 max_surf = 0; 00880 for ( ldp = 0; ldp < ldp_list->nused; ldp++ ) /* does this ldp exist? */ 00881 if ( ldp_list->list[ldp].nsurf > max_surf ) 00882 max_surf = ldp_list->list[ldp].nsurf; 00883 00884 /* and allocate */ 00885 surfs = (int *)malloc(max_surf * sizeof(int)); 00886 if ( !surfs ) { 00887 fprintf(stderr,"** scs: failed to allocate %d ints\n", max_surf); 00888 exit(1); 00889 } 00890 00891 /* now process each LDP */ 00892 for ( ldp = 0; ldp < ldp_list->nused; ldp++ ) { 00893 lsurf = &ldp_list->list[ldp]; /* set pointer */ 00894 /* if( nsurf < 2 ) continue; 00895 - must still slist_check_user_surfs() 11 Jan 2004 [rickr] */ 00896 00897 if ( slist_surfs_for_ldp(lsurf, surfs, max_surf, sess, po->sopt.debug) ) 00898 continue; /* try with current sa sb */ 00899 00900 slist_check_user_surfs(lsurf, surfs, po);/* proceed even on failure */ 00901 00902 if ( lsurf->sB < 0 ) first = 1; /* we know nsurf >= 2 */ 00903 else first = 2; 00904 00905 /* if something is discarded and using defaults or debug */ 00906 if ( (first < lsurf->nsurf) && (! lsurf->use_v2s || po->sopt.debug > 1) ){ 00907 fprintf(stderr, 00908 "--------------------------------------------------\n" 00909 "received too many surfaces for LDP '%s'\n", 00910 lsurf->full_label_ldp[0] ? lsurf->full_label_ldp : lsurf->label_ldp); 00911 for ( surf = 0; surf < first; surf++ ) 00912 fprintf(stderr," using surf #%d : %s\n", 00913 surfs[surf], sess->su_surf[surfs[surf]]->label); 00914 for ( surf = first; surf < lsurf->nsurf; surf++ ) 00915 fprintf(stderr," ignoring surf #%d : %s\n", 00916 surfs[surf], sess->su_surf[surfs[surf]]->label); 00917 } 00918 } 00919 00920 free(surfs); 00921 00922 RETURN(0); 00923 } |
|
construct list of surfaces for this LDP 21 Oct 2004 [rickr] Definition at line 1031 of file afni_niml.c. References ENTRY, ldp_surf_list::full_label_ldp, SUMA_surface::idcode, SUMA_surface::idcode_ldp, ldp_surf_list::idcode_ldp, SUMA_surface::label, SUMA_surface::label_ldp, ldp_surf_list::label_ldp, ldp_surf_list::nsurf, RETURN, ldp_surf_list::sA, ldp_surf_list::sB, THD_session::su_num, and THD_session::su_surf. Referenced by slist_choose_surfs().
01033 { 01034 SUMA_surface * ss; 01035 int count, surf, len; 01036 01037 ENTRY("slist_surfs_for_ldp"); 01038 01039 if ( debug > 2 ) 01040 fprintf(stderr,"-d ss_for_ldp: LDP '%s', ldp.nsurf = %d, su_num = %d\n", 01041 lsurf->label_ldp, lsurf->nsurf, sess->su_num); 01042 01043 count = 0; 01044 for ( surf = 0; surf < sess->su_num; surf++ ) 01045 { 01046 ss = sess->su_surf[surf]; 01047 01048 if ( strncmp(lsurf->idcode_ldp, ss->idcode_ldp, 32) == 0 ) { 01049 if (count >= max) { 01050 fprintf(stderr,"** failure: ss_for_ldp #1 (%s: %d,%d,%d)\n", 01051 lsurf->label_ldp, surf, count, max); 01052 RETURN(1); 01053 } 01054 01055 if ( debug > 2 ) 01056 fprintf(stderr,"-d surfs_for_ldp: surf %d '%s' matches LDP '%s'\n", 01057 surf, ss->label, ss->label_ldp); 01058 01059 /* found a surface for this LDP: note it and check if it is LDP */ 01060 surfs[count++] = surf; 01061 len = strlen(ss->label_ldp); 01062 if ( ((len >= 4) && (strncmp(ss->label+len-4, "SAME", 4) == 0)) || 01063 (strncmp(lsurf->idcode_ldp, ss->idcode, 64) == 0) ) { 01064 /* then this surface is also a Local Domain Parent */ 01065 strncpy(lsurf->full_label_ldp, ss->label, 63); 01066 lsurf->full_label_ldp[63] = '\0'; 01067 if ( strlen(lsurf->full_label_ldp) < (63 - 11) ) 01068 strcat(lsurf->full_label_ldp, " (via SAME)"); 01069 01070 if ( debug > 2 ) 01071 fprintf(stderr,"-d surfs_for_ldp: surf %d '%s' is LDP '%s'\n", 01072 surf, ss->label, lsurf->full_label_ldp); 01073 } 01074 } 01075 } 01076 01077 /* do a little quick verification that the first 1 or 2 match sa and sb */ 01078 if ( lsurf->sA != surfs[0] ) { 01079 fprintf(stderr,"** failure: ss_for_ldp #2 (%d,%d)\n",lsurf->sA,surfs[0]); 01080 RETURN(1); 01081 } 01082 if ( lsurf->nsurf > 1 && lsurf->sB != surfs[1] ) { 01083 fprintf(stderr,"** failure: ss_for_ldp #3 (%d,%d)\n",lsurf->sB,surfs[1]); 01084 RETURN(1); 01085 } 01086 /* and that we didn't miss anything */ 01087 if ( count != lsurf->nsurf ) { 01088 fprintf(stderr,"** failure: ss_for_ldp #4 (%d,%d)\n",count,lsurf->nsurf); 01089 RETURN(1); 01090 } 01091 01092 RETURN(0); 01093 } |
Variable Documentation
|
If 1, won't listen to info from SUMA Definition at line 87 of file afni_niml.c. |
|
If 1, won't send func overlay to SUMA Definition at line 82 of file afni_niml.c. Referenced by AFNI_disable_suma_overlay(), AFNI_niml_redisplay_CB(), AFNI_niml_workproc(), and process_NIML_Node_ROI(). |
|
If 1, won't send info to SUMA Definition at line 78 of file afni_niml.c. Referenced by AFNI_niml_redisplay_CB(), AFNI_niml_viewpoint_CB(), AFNI_niml_workproc(), process_NIML_SUMA_crosshair_xyz(), process_NIML_SUMA_ijk(), process_NIML_SUMA_ixyz(), and process_NIML_SUMA_node_normals(). |
|
if 1, display some messages as popups, else to terminal Definition at line 92 of file afni_niml.c. Referenced by AFNI_init_niml(). |
|
Array of stream flags Definition at line 56 of file afni_niml.c. Referenced by AFNI_init_niml(), and AFNI_niml_workproc(). |
|
Array of streams on which to listen Definition at line 46 of file afni_niml.c. |
|
Array of stream names to open Definition at line 51 of file afni_niml.c. Referenced by AFNI_init_niml(), and AFNI_niml_workproc(). |
|
Definition at line 146 of file afni_niml.c. Referenced by AFNI_init_niml(). |
|
If 1, send data; if 0, debug print it instead Definition at line 138 of file afni_niml.c. Referenced by AFNI_init_niml(). |
|
Definition at line 139 of file afni_niml.c. Referenced by AFNI_init_niml(), and AFNI_niml_redisplay_CB(). |
|
Flag to tell if NIML things are initialized. Definition at line 144 of file afni_niml.c. Referenced by AFNI_init_niml(). |
|
Definition at line 147 of file afni_niml.c. Referenced by AFNI_init_niml(). |