Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
thd_reconpar.c
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 #include "mrilib.h"
00008 #include "thd.h"
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 # define IFNOANAT(ds)                                           \
00017    if( needed && (ds)->anat_parent == NULL )                    \
00018       fprintf(stderr, "\n** Can't find anat parent %s of %s",   \
00019              (ds)->anat_parent_idcode.str , DSET_HEADNAME(ds) )
00020 
00021 # define IFNOWARP(ds)                                             \
00022    if( needed && (ds)->warp_parent == NULL && ! DSET_ONDISK(ds) ) \
00023       fprintf(stderr, "\n** Can't find warp parent %s of %s",     \
00024              (ds)->warp_parent_idcode.str , DSET_HEADNAME(ds) )
00025 
00026 #if 0
00027 # define SHOW_PARENTING(str,ds,dsp)                                            \
00028   ( printf("THD_reconcile_parents: %s of %s to %s\n",                          \
00029            str,(ds)->dblk->diskptr->filecode,(dsp)->dblk->diskptr->filecode) , \
00030     fflush(stdout) )
00031 #else
00032 # define SHOW_PARENTING(str,ds,dsp) 
00033 #endif
00034 
00035 void THD_reconcile_parents( THD_sessionlist * ssl )
00036 {
00037    int iss , idd , ivv , jss , imm , needed ;
00038    THD_session      * sess ;
00039    THD_3dim_dataset * dset_orph ;
00040    THD_slist_find   find ;
00041 
00042 ENTRY("THD_reconcile_parents") ;
00043 
00044    
00045 
00046    if( ! ISVALID_SESSIONLIST(ssl) || ssl->num_sess <= 0 ) EXRETURN ;
00047 
00048    
00049 
00050    for( iss=0 ; iss < ssl->num_sess ; iss++ ){
00051       sess = ssl->ssar[iss] ;
00052 
00053       
00054 
00055       for( idd=0 ; idd < sess->num_dsset ; idd++ ){
00056          for( ivv=FIRST_VIEW_TYPE ; ivv <= LAST_VIEW_TYPE ; ivv++ ){
00057 
00058           dset_orph = sess->dsset[idd][ivv] ;
00059           if( dset_orph == NULL ) continue ;
00060 
00061             
00062 
00063           if( dset_orph->anat_parent == NULL ){  
00064             needed = 0 ;
00065             if( ! ISZERO_IDCODE(dset_orph->anat_parent_idcode) ){
00066                needed = 1 ;
00067                find = THD_dset_in_sessionlist( FIND_IDCODE ,
00068                                                &(dset_orph->anat_parent_idcode),
00069                                                ssl , iss ) ;
00070                dset_orph->anat_parent = find.dset ;
00071                if( dset_orph->anat_parent != NULL )
00072                   SHOW_PARENTING("(ID) anat_parent",dset_orph,dset_orph->anat_parent) ;
00073             }
00074             if( dset_orph->anat_parent == NULL && strlen(dset_orph->anat_parent_name) > 0 ){
00075                needed = 1 ;
00076                find = THD_dset_in_sessionlist( FIND_NAME ,
00077                                                dset_orph->anat_parent_name,
00078                                                ssl , iss ) ;
00079                dset_orph->anat_parent = find.dset ;
00080                if( dset_orph->anat_parent != NULL )
00081                   SHOW_PARENTING("(NAME) anat_parent",dset_orph,dset_orph->anat_parent) ;
00082             }
00083             IFNOANAT(dset_orph) ;
00084           }
00085 
00086             
00087 
00088           if( dset_orph->warp_parent == NULL ){  
00089             needed = 0 ;
00090             if( ! ISZERO_IDCODE(dset_orph->warp_parent_idcode) ){
00091                needed = 1 ;
00092                find = THD_dset_in_sessionlist( FIND_IDCODE ,
00093                                                &(dset_orph->warp_parent_idcode),
00094                                                ssl , iss ) ;
00095                dset_orph->warp_parent = find.dset ;
00096                if( dset_orph->warp_parent != NULL )
00097                   SHOW_PARENTING("(ID) warp_parent",dset_orph,dset_orph->warp_parent) ;
00098             }
00099             if( dset_orph->warp_parent == NULL && strlen(dset_orph->warp_parent_name) > 0 ){
00100                needed = 1 ;
00101                find = THD_dset_in_sessionlist( FIND_NAME ,
00102                                                dset_orph->warp_parent_name,
00103                                                ssl , iss ) ;
00104                dset_orph->warp_parent = find.dset ;
00105                if( dset_orph->warp_parent != NULL )
00106                   SHOW_PARENTING("(NAME) warp_parent",dset_orph,dset_orph->warp_parent) ;
00107             }
00108             IFNOWARP(dset_orph) ;
00109           }
00110 
00111          }
00112       }  
00113 
00114    }  
00115 
00116    EXRETURN ;
00117 }