Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

SUMA_Color.h File Reference

Go to the source code of this file.


Defines

#define SUMA_ADD_COORD_BIAS_VECT(SO, ovr, BiasDim, BiasVect)

Functions

SUMA_COLOR_MAPSUMA_MakeColorMap (float **Fiducials, int Nfid, int Ncols, SUMA_Boolean SkipLast, char *Name)
void SUMA_Free_ColorMap (SUMA_COLOR_MAP *SM)
int r_ulong_size (unsigned long l)
int r_sprintf_long_to_hex (char *dest, unsigned long lsrc, int bytes, int pad)
SUMA_SCALE_TO_MAP_OPTSUMA_ScaleToMapOptInit (void)
void SUMA_Free_ColorScaledVect (SUMA_COLOR_SCALED_VECT *S)
SUMA_COLOR_SCALED_VECTSUMA_Create_ColorScaledVect (int N_Node)
SUMA_Boolean SUMA_ScaleToMap (float *V, int N_V, float Vmin, float Vmax, SUMA_COLOR_MAP *ColMap, SUMA_SCALE_TO_MAP_OPT *Opt, SUMA_COLOR_SCALED_VECT *SV)
SUMA_COLOR_MAPSUMA_GetStandardMap (SUMA_STANDARD_CMAP mapname)
float * SUMA_PercRange (float *V, float *Vsort, int N_V, float *PercRange, float *PercRangeVal, int *iPercRange)
double * SUMA_dPercRange (double *V, double *Vsort, int N_V, double *PercRange, double *PercRangeVal, int *iPercRangeVal)
SUMA_COLOR_MAPSUMA_MakeColorMap_v2 (float **Fiducials, int Nfid, int *Nint, SUMA_Boolean SkipLast, char *Name)
SUMA_OVERLAYSSUMA_CreateOverlayPointer (int N_Nodes, const char *Name, SUMA_DSET *dset, char *owner_id)
SUMA_Boolean SUMA_FreeOverlayPointer (SUMA_OVERLAYS *Sover)
SUMA_Boolean SUMA_Overlays_2_GLCOLAR4 (SUMA_SurfaceObject *SO, SUMA_SurfaceViewer *sv, GLfloat *glcolar)
SUMA_OVERLAYSSUMA_Fetch_OverlayPointer (SUMA_OVERLAYS **Overlays, int N_Overlays, const char *Name, int *OverInd)
SUMA_Boolean SUMA_Show_ColorOverlayPlanes (SUMA_OVERLAYS **Overlays, int N_Overlays, int detail)
char * SUMA_ColorOverlayPlane_Info (SUMA_OVERLAYS **Overlays, int N_Overlays, int detail)
 Shows the contents of the color overlay planes.

SUMA_Boolean SUMA_MixOverlays (SUMA_OVERLAYS **Overlays, int N_Overlays, int *ShowOvelays, int N_ShowOverlays, GLfloat *glcolar, int N_Node, SUMA_Boolean *isColored, SUMA_Boolean FILL)
SUMA_Boolean SUMA_MixColors (SUMA_SurfaceViewer *sv)
 ans = SUMA_MixColors (sv); this functions mixes the colors for surface objects that ask for it

SUMA_Boolean SUMA_iRGB_to_OverlayPointer (SUMA_SurfaceObject *SO, char *Name, SUMA_OVERLAY_PLANE_DATA *sopd, int *PlaneInd, SUMA_DO *dov, int N_dov, DList *DsetList)
 A function that looks up an overlay plane by its name. If the plane is found its index is returned, otherwise a new one is created. The function also sets up pointers to that plane for all related surfaces in dov and places node colors in that plane.

SUMA_Boolean SUMA_CompactOverlaysOrder (SUMA_SurfaceObject *SO)
void SUMA_FreeOverlayListDatum (void *OLDv)
 Frees SUMA_OVERLAY_LIST_DATUM * used in the linked list.

SUMA_Boolean SUMA_AddNewPlane (SUMA_SurfaceObject *SO, SUMA_OVERLAYS *Overlay, SUMA_DO *dov, int N_dov, int DupFlag)
 Adds a new plane to SO->Overlays. If plane exists, you get an error message Adds plane to related surfaces if dov is not NULL.

SUMA_Boolean SUMA_isOverlayOfSO (SUMA_SurfaceObject *SO, SUMA_OVERLAYS *Plane)
int SUMA_GetSmallestForegroundOrder (DList *listop)
 returns the lowest foreground plane order in the list of overlay planes

int SUMA_GetLargestBackroundOrder (DList *listop)
 returns the largest background order in the list of verlay planes

DListSUMA_OverlaysToOrderedList (SUMA_SurfaceObject *SO, int Opt)
 Create an ordered list of the colorplanes in Overlays the sorting of the list is done based on BackMod followed by the order The function makes sure colorplane orders span 0 to N_Overlays-1.

SUMA_Boolean SUMA_ReleaseOverlay (SUMA_OVERLAYS *Overlays, SUMA_INODE *Overlays_Inode)
 releases an overlay pointer (decrement its inode count and free it if necessary)

char * SUMA_PlaneOrder_Info (SUMA_SurfaceObject *SO)
 Shows the overlay plane order.

void SUMA_Print_PlaneOrder (SUMA_SurfaceObject *SO, FILE *Out)
SUMA_Boolean SUMA_ListOrderToPlaneOrder (DList *listop)
 sets the values of PlaneOrder to reflect the location of the color planes in list

SUMA_Boolean SUMA_MovePlaneUp (SUMA_SurfaceObject *SO, char *Name)
 Moves a plane up one order.

SUMA_Boolean SUMA_MovePlaneDown (SUMA_SurfaceObject *SO, char *Name)
 Moves a plane up one order.

void SUMA_LoadDsetFile (char *filename, void *data)
 Loads a Dset file and adds it to the list of datasets.

void SUMA_LoadColorPlaneFile (char *filename, void *data)
 Loads a color plane file and adds it to a surface's list of colorplanes.

SUMA_ASSEMBLE_LIST_STRUCTSUMA_AssembleColorPlaneList (SUMA_SurfaceObject *SO)
 Returns a list of the Colorplanes belonging to a certain surface.

void SUMA_RefreshDsetList (SUMA_SurfaceObject *SO)
 refreshes a colorplane list. A combo of SUMA_AssembleColorPlaneList and SUMA_CreateScrolledList.

SUMA_Boolean SUMA_FlushPlaneNotInUse (char *PlaneName, SUMA_SurfaceObject *SO, SUMA_DO *dov, int N_dov)
 SUMA_FlushPlaneNotInUse (char *PlaneName, SUMA_SurfaceObject *SO, SUMA_DO *dov, int N_dov) Searches all DrawnROIs in dov. If no ROI related to SO has PlaneName for a color plane then that colorplane is flushed (ie no node colors are left in it, not deleted).

SUMA_STANDARD_CMAP SUMA_StandardMapCode (char *Name)
 Returns the code corresponding to a colormap name.

char * SUMA_StandardMapName (SUMA_STANDARD_CMAP mapcode, int *N_col)
 Returns the ascii name of a Suma standard map.

SUMA_COLOR_MAPSUMA_Linearize_Color_Map (SUMA_COLOR_MAP *SM, int N_lin)
SUMA_COLOR_MAPSUMA_Read_Color_Map_1D (char *Name)
SUMA_Boolean SUMA_ScaleToMap_alaAFNI (float *V, int N_V, float range, SUMA_COLOR_MAP *ColMap, SUMA_SCALE_TO_MAP_OPT *Opt, SUMA_COLOR_SCALED_VECT *SV)
SUMA_AFNI_COLORSSUMA_Get_AFNI_Default_Color_Maps ()
 Builds the SUMA_AFNI_COLORS structure which contains the Named colors and colormaps defined in AFNI The colors and colormaps loaded are the ones that are found in AFNI when AFNI is first started.

SUMA_COLOR_MAP ** SUMA_Add_ColorMap (SUMA_COLOR_MAP *CM, SUMA_COLOR_MAP **OldCMv, int *N_maps)
 A function to add a new colormap to the colormap vector.

SUMA_RGB_NAMESUMA_Add_Color (char *Name, float r, float g, float b, float a, SUMA_RGB_NAME *oCv, int *N_cols)
 A function to add a new color to the color vector.

char * SUMA_ColorMapVec_Info (SUMA_COLOR_MAP **CMv, int N_maps, int detail)
 List the colormaps in the vector.

char * SUMA_ColorVec_Info (SUMA_RGB_NAME *Cv, int N_cols)
 List the colors in the vector.

void SUMA_Show_ColorMapVec (SUMA_COLOR_MAP **CMv, int N_maps, FILE *Out, int detail)
 Shows the contents of the colormaps vector.

void SUMA_Show_ColorVec (SUMA_RGB_NAME *CMv, int N_maps, FILE *Out)
 Shows the contents of the color vector.

int SUMA_Find_ColorMap (char *Name, SUMA_COLOR_MAP **CMv, int N_maps, int sgn)
 Locate a colormap in the colormap vector.

int SUMA_Find_Color (char *Name, SUMA_RGB_NAME *Cv, int N_cols)
 Locate a color in the color vector.

SUMA_AFNI_COLORSSUMA_DestroyAfniColors (SUMA_AFNI_COLORS *SAC)
 Cleans up and destroys the contents of the SUMA_AFNI_COLORS.

SUMA_Boolean SUMA_Interpret_AFNIColor (char *Name, float RGB[3])
 turns a color defined by it's Xname or AFNI Hex formulation into good old RGB

int SUMA_AFNI_Extract_Colors (char *fname, SUMA_AFNI_COLORS *SAC)
 Extracts colors and colormaps from AFNI formatted .pal files Also used to extract such info from .afnirc file.

void SUMA_Flip_Color_Map (SUMA_COLOR_MAP *CM)
 flips a color map upside down

int SUMA_ColorizePlane (SUMA_OVERLAYS *cp)
 colorize the data of the colorplane

SUMA_AFNI_COLORSSUMA_Build_Color_maps (void)
 creates the colormaps available for SUMA

char * SUMA_ScaleToMapOpt_Info (SUMA_SCALE_TO_MAP_OPT *OptScl, int detail)
SUMA_Boolean SUMA_ShowScaleToMapOpt (SUMA_SCALE_TO_MAP_OPT *OptScl, FILE *Out, int detail)
SUMA_Boolean SUMA_SetConvexityPlaneDefaults (SUMA_SurfaceObject *SO, DList *DsetList)
 Sets up the defaults for the convexity plane.

SUMA_COLOR_MAPSUMA_CmapOfPlane (SUMA_OVERLAYS *Sover)
 Find the colormap associated with a colorplane.

SUMA_Boolean SUMA_SetSO_CoordBias (SUMA_SurfaceObject *SO, SUMA_OVERLAYS *ovr, float *NewBias, SUMA_WIDGET_INDEX_COORDBIAS BiasDim)
SUMA_Boolean SUMA_SetCoordBias (SUMA_OVERLAYS *ovr, float *NewBias, SUMA_WIDGET_INDEX_COORDBIAS BiasDim)
SUMA_Boolean SUMA_RemoveSO_CoordBias (SUMA_SurfaceObject *SO, SUMA_OVERLAYS *ovr)
SUMA_Boolean SUMA_RemoveCoordBias (SUMA_OVERLAYS *ovr)
SUMA_Boolean SUMA_TransferSO_CoordBias (SUMA_SurfaceObject *SO, SUMA_OVERLAYS *ovr, SUMA_WIDGET_INDEX_COORDBIAS BiasDim)
SUMA_Boolean SUMA_TransferCoordBias (SUMA_OVERLAYS *ovr, SUMA_WIDGET_INDEX_COORDBIAS BiasDim)
SUMA_Boolean SUMA_NewSurfaceGeometry (SUMA_SurfaceObject *SO)
int SUMA_GetNodeOverInd (SUMA_OVERLAYS *Sover, int node)
 j = SUMA_GetNodeOverInd(Sover, node); returns the index, into Sover->NodeDef such that Sover->NodeDef[j] = node;

SUMA_Boolean SUMA_isDsetColumn_inferred (SUMA_DSET *dset, int icol)
SUMA_Boolean SUMA_AddNodeIndexColumn (SUMA_DSET *dset, SUMA_SurfaceObject *SO)
SUMA_Boolean SUMA_OKassign (SUMA_DSET *dset, SUMA_SurfaceObject *SO)
 determines if a Dset can be assigned to a surface object


Define Documentation

#define SUMA_ADD_COORD_BIAS_VECT SO,
ovr,
BiasDim,
BiasVect   
 

Definition at line 4 of file SUMA_Color.h.

Referenced by SUMA_GetOverlaysFromParent(), SUMA_SetSO_CoordBias(), and SUMA_TransferSO_CoordBias().


Function Documentation

int r_sprintf_long_to_hex char *    dest,
unsigned long    lsrc,
int    bytes,
int    pad
 

---------------------------------------------------------------------- sprintf_long_to_hex - write hex chars to a string

return number of hex pairs written (should equal bytes) ----------------------------------------------------------------------

Definition at line 77 of file r_misc.c.

References pad(), r_ulong_size(), and ulong_size().

00083 {
00084     static char hexstring[] = "0123456789ABCDEF";
00085 
00086     unsigned char   ub;
00087     char          * cp = dest;
00088     int             posn, size, ret;
00089 
00090     if ( (bytes <= 0) || (bytes > 4) )
00091     {
00092         *cp = '\0';
00093         return 0;
00094     }
00095 
00096     size = ulong_size( lsrc );
00097 
00098     if ( (size < bytes) && !pad )       /* use size if we avoid padding  */
00099         ret = size;
00100     else
00101         ret = bytes;
00102 
00103     for ( posn = ret-1; posn >= 0; posn-- )
00104     {
00105         /* write one hex pair for this byte */
00106         ub = ( lsrc >> (posn << 3) ) & 0xff;            /* current ubyte */
00107         *cp++ = hexstring[(ub>>4) & 0xf];               /* upper nibble  */
00108         *cp++ = hexstring[ ub     & 0xf];               /* lower nibble  */
00109     }
00110 
00111     *cp = '\0';
00112 
00113     return ret;
00114 }

int r_ulong_size unsigned long    l
 

Definition at line 1290 of file SUMA_Color.c.

References l.

Referenced by r_sprintf_long_to_hex().

01291 {
01292     if ( l & 0xff000000 )
01293    return 4;
01294 
01295     if ( l & 0xff0000 )
01296    return 3;
01297 
01298     if ( l & 0xff00 )
01299    return 2;
01300 
01301     return 1;
01302 } 

SUMA_RGB_NAME* SUMA_Add_Color char *    Name,
float    r,
float    g,
float    b,
float    a,
SUMA_RGB_NAME   oCv,
int *    N_cols
 

A function to add a new color to the color vector.

Parameters:
Name  (char *) name of new color to be added
r  (float) r color ( 0 <= r <= 1)
g  (float) g color ( 0 <= g <= 1)
b  (float) b color ( 0 <= b <= 1)
a  (float) a color ( 0 <= a <= 1)
  • You are allowed to pass -1.0, -1.0, -1.0 for r g b to define the No-Color
Parameters:
oCv  (SUMA_RGB_NAME*) old vector containing color structs
N_cols  (int *) number of colors in oCv When the function returns, this number will include the added color
Returns:
NewCv (SUMA_RGB_NAME *) you know what. If the color being added exists (by Name), it will replace the preexisting one
  • New space is allocated for each new color (realloc).
  • This process is not terribly efficient by not many colors are loaded in this manner.
  • You can send NULL for oCv if this vector has yet to be created

Definition at line 584 of file SUMA_Color.c.

References SUMA_RGB_NAME::a, a, SUMA_RGB_NAME::b, SUMA_RGB_NAME::g, LocalHead, SUMA_RGB_NAME::r, r, SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_Find_Color(), SUMA_LH, SUMA_MAX_COLOR_NAME, SUMA_realloc, SUMA_RETURN, and SUMA_S_Err.

Referenced by SUMA_AFNI_Extract_Colors(), and SUMA_Get_AFNI_Default_Color_Maps().

00585 {
00586    static char FuncName[]={"SUMA_Add_Color"};
00587    SUMA_RGB_NAME *NewCv = NULL;
00588    int iadd;
00589    SUMA_Boolean LocalHead = NOPE;
00590    
00591    SUMA_ENTRY;
00592    
00593    if (!(r == -1.0 && g == -1.0 && b == -1.0)) {
00594       if (  r < 0 || r > 1 ||
00595             g < 0 || g > 1 ||
00596             b < 0 || b > 1 ||
00597             a < 0 || a > 1 ) {
00598          SUMA_S_Err("Bad r, g, b and/or a values.\nMust be between 0 and 1.Nothing done.");
00599          SUMA_RETURN(oCv);
00600       }
00601    }else {
00602       SUMA_LH("No color");
00603    }
00604    
00605    if (strlen(Name) > SUMA_MAX_COLOR_NAME -1 ) {
00606       SUMA_S_Err("Too long a color name\n(> SUMA_MAX_COLOR_NAME)\nNothing done.");
00607       SUMA_RETURN(oCv);
00608    }
00609    
00610    if (!oCv) {
00611       SUMA_LH("New color vector, allocating");
00612       NewCv = (SUMA_RGB_NAME *) SUMA_calloc(1, sizeof(SUMA_RGB_NAME));
00613       *N_cols = 1;
00614       NewCv[*N_cols-1].r = r;
00615       NewCv[*N_cols-1].g = g;
00616       NewCv[*N_cols-1].b = b;
00617       NewCv[*N_cols-1].a = a;
00618       sprintf(NewCv[*N_cols-1].Name, "%s", Name);
00619       SUMA_RETURN(NewCv);
00620    }
00621    
00622    /* not new, check to see if color exists already */
00623    iadd = SUMA_Find_Color (Name, oCv, *N_cols);
00624    
00625    if (iadd >= 0) {
00626       SUMA_LH("Replacing old color");
00627       NewCv = oCv;
00628       NewCv[iadd].r = r;
00629       NewCv[iadd].g = g;
00630       NewCv[iadd].b = b;
00631       NewCv[iadd].a = a;
00632       SUMA_RETURN(oCv);
00633    }
00634    
00635    /* a new map altogether */
00636    SUMA_LH("Adding new color");
00637    *N_cols += 1;
00638    NewCv = (SUMA_RGB_NAME *) SUMA_realloc(oCv, *N_cols * sizeof(SUMA_RGB_NAME));
00639    NewCv[*N_cols-1].r = r;
00640    NewCv[*N_cols-1].g = g;
00641    NewCv[*N_cols-1].b = b;
00642    NewCv[*N_cols-1].a = a;
00643    sprintf(NewCv[*N_cols-1].Name, "%s", Name);
00644 
00645    SUMA_RETURN(NewCv);
00646 }

SUMA_COLOR_MAP** SUMA_Add_ColorMap SUMA_COLOR_MAP   CM,
SUMA_COLOR_MAP **    OldCMv,
int *    N_maps
 

A function to add a new colormap to the colormap vector.

Parameters:
CM  (SUMA_COLOR_MAP *) new color map to be added
OldCMv  (SUMA_COLOR_MAP **) old vector containing pointers to colormaps
N_map  (int *) number of maps in OldCMv When the function returns, this number will include the added map
Returns:
NewCMv (SUMA_COLOR_MAP **) you know what. If the map being added exists (by Name), it will replace the preexisting one
  • New space is allocated for each new map (realloc).
  • This process is not terribly efficient by not many maps are loaded in this manner.
  • You can send NULL for OldCMv if this vector has yet to be created
  • Color map structure is copied by reference. Do not free it.

Definition at line 665 of file SUMA_Color.c.

References LocalHead, SUMA_COLOR_MAP::Name, SUMA_COLOR_MAP::Sgn, SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_Find_ColorMap(), SUMA_Free_ColorMap(), SUMA_LH, SUMA_realloc, SUMA_RETURN, and SUMA_S_Warn.

Referenced by SUMA_AFNI_Extract_Colors(), SUMA_Build_Color_maps(), SUMA_Get_AFNI_Default_Color_Maps(), and SUMA_LoadCmapFile().

00666 {
00667    static char FuncName[]={"SUMA_Add_ColorMap"};
00668    SUMA_COLOR_MAP ** NewCMv = NULL;
00669    int iadd;
00670    SUMA_Boolean LocalHead = NOPE;
00671    
00672    SUMA_ENTRY;
00673 
00674    if (!CM) {
00675       SUMA_S_Warn("Null CM, nothing to do");
00676       SUMA_RETURN(OldCMv);
00677    }
00678    if (!OldCMv) {
00679       SUMA_LH("New color vector, allocating");
00680       NewCMv = (SUMA_COLOR_MAP **) SUMA_calloc(1, sizeof(SUMA_COLOR_MAP *));
00681       *N_maps = 1;
00682       NewCMv[0] = CM;
00683       SUMA_RETURN(NewCMv);
00684    }
00685    
00686    /* not new, check to see if map exists already */
00687    iadd = SUMA_Find_ColorMap (CM->Name, OldCMv, *N_maps, CM->Sgn);
00688    if (iadd >= 0) {
00689       SUMA_LH("Replacing old colormap");
00690       SUMA_Free_ColorMap (OldCMv[iadd]);
00691       OldCMv[iadd] = CM;
00692       SUMA_RETURN(OldCMv);
00693    }
00694    
00695    /* a new map altogether */
00696    SUMA_LH("Adding new color map");
00697    *N_maps += 1;
00698    NewCMv = (SUMA_COLOR_MAP **) SUMA_realloc(OldCMv, *N_maps * sizeof(SUMA_COLOR_MAP *));
00699    NewCMv[*N_maps - 1] = CM;
00700    
00701    SUMA_RETURN(NewCMv);
00702 }

SUMA_Boolean SUMA_AddNewPlane SUMA_SurfaceObject   SO,
SUMA_OVERLAYS   Overlay,
SUMA_DO   dov,
int    N_dov,
int    DuplicateFlag
 

Adds a new plane to SO->Overlays. If plane exists, you get an error message Adds plane to related surfaces if dov is not NULL.

DuplicateFlag == 0 return with error if plane already exists 1 return with warning if plane already exists

Definition at line 5915 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::BiasVect, dlist_destroy(), dlist_ins_next(), dlist_tail, i, SUMA_OVERLAYS::isBackGrnd, LocalHead, SUMA_SurfaceObject::N_Overlays, SUMA_OVERLAYS::Name, SUMA_OVERLAYS::OptScl, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_SurfaceObject::Overlays, SUMA_OVERLAYS::PlaneOrder, DList_::size, SUMA_Boolean, SUMA_ENTRY, SUMA_Fetch_OverlayPointer(), SUMA_free, SUMA_isOverlayOfSO(), SUMA_isRelated(), SUMA_isSO(), SUMA_LH, SUMA_LinkToPointer(), SUMA_malloc, SUMA_MAX_OVERLAYS, SUMA_OverlaysToOrderedList(), SUMA_RETURN, SUMA_S_Err, SUMA_S_Warn, SUMA_SL_Crit, and SUMA_SL_Err.

Referenced by SUMA_iRGB_to_OverlayPointer(), SUMA_LoadDsetFile(), and SUMA_PrepAddmappableSO().

05916 {
05917    static char FuncName[]={"SUMA_AddNewPlane"};
05918    DList *ForeList=NULL, *BackList = NULL;
05919    SUMA_OVERLAY_LIST_DATUM *OvD=NULL;
05920    int junk=0, i, OverInd;
05921    SUMA_SurfaceObject *SO2 = NULL;
05922    SUMA_Boolean LocalHead = NOPE;
05923    
05924    SUMA_ENTRY; 
05925    
05926    if (!Overlay) {
05927       SUMA_S_Err("You sent me NULLS!");
05928       SUMA_RETURN (NOPE);
05929    }
05930    
05931    if (SUMA_isOverlayOfSO(SO, Overlay)) {
05932       if (DuplicateFlag == 0) {
05933          SUMA_S_Err("Plane exists in SO->Overlays.");
05934          SUMA_RETURN (NOPE);
05935       } else {
05936          SUMA_S_Warn("Plane exists in SO->Overlays. Preserving old one.");
05937          SUMA_RETURN (YUP);
05938       }
05939    }
05940    
05941    /* also try looking for plane by name */
05942    if (SUMA_Fetch_OverlayPointer(SO->Overlays, SO->N_Overlays, Overlay->Name, &junk)) {
05943       if (DuplicateFlag == 0) {   
05944          SUMA_S_Err("Plane exists in SO->Overlays (identified by name).");
05945          SUMA_RETURN (NOPE);
05946       } else {
05947          SUMA_S_Warn("Plane exists in SO->Overlays (identified by name). Preserving old one.");
05948          SUMA_RETURN (YUP);
05949       }
05950    }
05951    
05952    /* make sure that overlay plane does not have bias in it */
05953    if (Overlay->OptScl) {
05954       if (Overlay->OptScl->BiasVect) {
05955          SUMA_SL_Err("New overlay plane cannot have coordinate bias.\nNot yet at least.\n");
05956          /* If you want to support this feature, you'll have to call SUMA_ADD_COORD_BIAS_VECT
05957          on any surface the plane gets assigned to. That means SO and SO2 below.
05958          Search for macro SUMA_ADD_COORD_BIAS_VECT in SUMA_SwitchState in file SUMA_Engine.c
05959          for the example */
05960          SUMA_RETURN(NOPE);
05961       }
05962    }
05963    /* make sure there's enough room for the new plane */
05964    if (SO->N_Overlays+1 >= SUMA_MAX_OVERLAYS) {
05965       SUMA_SL_Crit("Too many color overlays.");
05966       SUMA_RETURN (NOPE);
05967    }
05968    
05969    /* Now add the plane where it belongs */
05970    if (!(ForeList = SUMA_OverlaysToOrderedList (SO, 1))) {
05971       SUMA_S_Err("NULL ForeList");
05972       SUMA_RETURN (NOPE);
05973    }
05974    if (!(BackList = SUMA_OverlaysToOrderedList (SO, -1))) {
05975       SUMA_S_Err("NULL BackList");
05976       SUMA_RETURN (NOPE);
05977    }
05978    
05979    SUMA_LH("Adding to list...");
05980    OvD = (SUMA_OVERLAY_LIST_DATUM *) SUMA_malloc(sizeof(SUMA_OVERLAY_LIST_DATUM));
05981    OvD->Overlay = Overlay;
05982    
05983    if (Overlay->isBackGrnd) {
05984       SUMA_LH("Back dude...");
05985       dlist_ins_next(BackList, dlist_tail(BackList), (void *)OvD);
05986       Overlay->PlaneOrder = BackList->size - 1;
05987    } else {
05988       SUMA_LH("Front dude...");
05989       dlist_ins_next(ForeList, dlist_tail(ForeList), (void *)OvD);
05990       Overlay->PlaneOrder = ForeList->size - 1;
05991    }
05992    
05993    SUMA_LH("Out dude...");
05994    /* place the Overlay plane and its inode in SO */
05995    SO->Overlays[SO->N_Overlays] = Overlay;
05996    /* Now increment the number of overlays to be in SO */
05997    ++SO->N_Overlays;
05998    
05999    
06000    SUMA_LH("Destruction...");
06001    dlist_destroy(ForeList); SUMA_free(ForeList);
06002    dlist_destroy(BackList); SUMA_free(BackList);
06003 
06004    /* Now register plane with surfaces deserving it*/
06005    if (dov) {
06006       SUMA_LH("Registering plane with surfaces deserving it");
06007       /* Now that you have the color overlay plane set, go about all the surfaces, searching for ones related to SO 
06008       and make sure they have this colorplane, otherwise, create a link to it. */   
06009       for (i=0; i < N_dov; ++i) {
06010          if (SUMA_isSO(dov[i])) { 
06011             SO2 = (SUMA_SurfaceObject *)dov[i].OP;
06012             if (SUMA_isRelated(SO, SO2, 1) && SO != SO2) { /* only 1st order kinship allowed */
06013                /* surfaces related and not identical, check on colorplanes */
06014                if (!SUMA_Fetch_OverlayPointer (SO2->Overlays, SO2->N_Overlays, Overlay->Name, &OverInd)) {
06015                   /* color plane not found, link to that of SO */
06016                   SO2->Overlays[SO2->N_Overlays] = (SUMA_OVERLAYS *)SUMA_LinkToPointer((void*)SO->Overlays[SO->N_Overlays-1]);
06017                   /*increment the number of overlay planes */
06018                   ++SO2->N_Overlays;
06019                } else {
06020                   /* colorplane found OK */
06021                }
06022             }
06023          }
06024       }
06025    }
06026    SUMA_RETURN (YUP);
06027 }

SUMA_Boolean SUMA_AddNodeIndexColumn SUMA_DSET   dset,
SUMA_SurfaceObject   SO
 

Definition at line 6567 of file SUMA_Color.c.

References SUMA_DSET::dnel, i, LocalHead, SUMA_SurfaceObject::N_Node, SUMA_AddDsetNelCol(), SUMA_Boolean, SUMA_DsetCol2Float(), SUMA_ENTRY, SUMA_free, SUMA_GetDsetColIndex(), SUMA_LH, SUMA_malloc, SUMA_NODE_INDEX, SUMA_RETURN, SUMA_SL_Err, SUMA_SLP_Note, Ti, and NI_element::vec_len.

Referenced by SUMA_OKassign().

06568 {
06569    static char FuncName[]={"SUMA_AddNodeIndexColumn"};
06570    float range[2];
06571    int *iv=NULL, i, N_i;
06572    float *T = NULL;
06573    int *Ti = NULL;
06574    SUMA_Boolean OKfirstCol = NOPE;
06575    SUMA_Boolean LocalHead = NOPE;
06576        
06577    SUMA_ENTRY;
06578    
06579    if (!dset) SUMA_RETURN(NOPE);
06580    if (!SO) SUMA_RETURN(NOPE);
06581    /* check for obvious insult */
06582    if (dset->dnel->vec_len > SO->N_Node) {
06583       SUMA_SL_Err("more values in dset than nodes in surface.");
06584       SUMA_RETURN(NOPE);
06585    }
06586    /* Check for Col Index*/
06587    iv = SUMA_GetDsetColIndex (dset, SUMA_NODE_INDEX, &N_i);
06588    if (!iv) {
06589       SUMA_LH("No node index column");
06590       /* would the first column work ? */
06591       T = SUMA_DsetCol2Float (dset, 0, 0);
06592       OKfirstCol = NOPE;
06593       if (!T) { SUMA_LH("First column does not cut it"); OKfirstCol = NOPE;}
06594       else {
06595          Ti = (int *)SUMA_malloc(sizeof(int)*dset->dnel->vec_len);
06596          SUMA_LH("Testing if node indices can be in 1st column...");
06597          /* check if all values are ints and if they are within 0 and SO->N_Node -1 */
06598          i=0;
06599          OKfirstCol = YUP;
06600          while (i <dset->dnel->vec_len && OKfirstCol) {
06601             Ti[i] = (int)T[i];
06602             if ( (T[i] != Ti[i]) || (T[i] < 0) || (T[i] >= SO->N_Node) ) OKfirstCol = NOPE;
06603             ++i;
06604          }
06605          
06606          if (!OKfirstCol) { 
06607             SUMA_SLP_Note( "Assuming node indexing\n"
06608                            "is explicit. \n"
06609                            "1st row is for node 0\n"
06610                            "2nd is for node 1, etc.\n" );
06611             for (i=0; i <dset->dnel->vec_len; ++i) Ti[i]=i;
06612             OKfirstCol = YUP;
06613          }else{
06614             char Name[500], Attr[500];
06615             SUMA_SLP_Note("Used column 0 as node indices.\nAdded a node index column nonetheless.");
06616             /* You can't just change the label and the type of the 0th column to be SUMA_NODE_INDEX because
06617             this column is float, not ints. Duplicate ahead...*/
06618          }
06619          
06620       }
06621       
06622       if (!OKfirstCol) {
06623          SUMA_LH("No node index could be created");
06624          if (Ti) SUMA_free(Ti); Ti = NULL;
06625          SUMA_RETURN(NOPE);
06626       }
06627       
06628       /* Now add Ti to the dataset as a node index column ... */
06629       /* if you change the column label's string ("Node Index (inferred)") 
06630       make sure you change SUMA_isColumn_inferred accordingly */
06631       if (!SUMA_AddDsetNelCol (dset, "Node Index (inferred)", SUMA_NODE_INDEX, (void *)Ti, NULL, 1)) {
06632          SUMA_SL_Err("Failed to add column");
06633          if (Ti) SUMA_free(Ti); Ti = NULL;
06634          SUMA_RETURN(NOPE);
06635       }
06636       
06637       /* all done */
06638       SUMA_LH("Added the index column, ciao");
06639       if (Ti) SUMA_free(Ti); Ti = NULL;
06640       SUMA_RETURN(YUP);
06641    } else {
06642       SUMA_LH("Node index column found");
06643       SUMA_free(iv); iv = NULL;
06644       /* Nothing to do, return on a positive note */
06645       SUMA_RETURN(YUP);      
06646    } 
06647    
06648    SUMA_SL_Err("why are you here ?");
06649    SUMA_RETURN(NOPE);
06650 }

int SUMA_AFNI_Extract_Colors char *    fname,
SUMA_AFNI_COLORS   SAC
 

Extracts colors and colormaps from AFNI formatted .pal files Also used to extract such info from .afnirc file.

Parameters:
fname  (char *) name of file containing colors. either .afnirc or a .pal file
SAC  (SUMA_AFNI_COLORS *) pointer to structure that will contain the default afni colors and colormaps. This structure must have been previously initialized in SUMA_Get_AFNI_Default_Color_Maps which also automatically scans ~/.afnirc then ./afnirc if the former one was not found.
Returns:
N_palsRead (int) number of palettes found and read -1 if trouble reading at least one of the palettes

Definition at line 7042 of file SUMA_Color.c.

References AFNI_suck_file(), SUMA_RGB_NAME::b, SUMA_AFNI_COLORS::CMv, SUMA_COLOR_MAP::cname, SUMA_AFNI_COLORS::Cv, SUMA_COLOR_MAP::frac, free, SUMA_RGB_NAME::g, left, LocalHead, SUMA_COLOR_MAP::M, SUMA_COLOR_MAP::N_Col, SUMA_AFNI_COLORS::N_cols, SUMA_AFNI_COLORS::N_maps, SUMA_COLOR_MAP::Name, NPANE_MAX, SUMA_RGB_NAME::r, right, SUMA_COLOR_MAP::Sgn, SUMA_COLOR_MAP::SO, SUMA_Add_Color(), SUMA_Add_ColorMap(), SUMA_allocate2D(), SUMA_Boolean, SUMA_calloc, SUMA_Find_Color(), SUMA_GETEQN, SUMA_GETSTR, SUMA_Interpret_AFNIColor(), SUMA_ISTARRED, SUMA_LH, SUMA_malloc, SUMA_NSBUF, SUMA_RETURN, SUMA_SL_Crit, SUMA_SL_Warn, SUMA_StringAppend(), THD_filename_ok(), and THD_filename_pure().

Referenced by SUMA_Get_AFNI_Default_Color_Maps().

07043 {
07044    static char FuncName[]={"SUMA_AFNI_Extract_Colors"};
07045    int    nbuf , nused , ii, ngood = -1;
07046    float rgb[3];
07047    char * fbuf , * fptr ;
07048    char str[SUMA_NSBUF] , left[SUMA_NSBUF] , middle[SUMA_NSBUF] , right[SUMA_NSBUF] ;
07049    SUMA_STRING *SS = NULL;
07050    SUMA_COLOR_MAP *CM=NULL;
07051    SUMA_Boolean LocalHead = NOPE;
07052    
07053    fbuf = AFNI_suck_file( fname ) ; if( fbuf == NULL ) { 
07054                                        SUMA_SL_Warn("File could not be read");
07055                                        SUMA_RETURN(-1) ; }
07056    nbuf = strlen(fbuf) ;            if( nbuf == 0    ) { 
07057                                        SUMA_SL_Warn("Empty  file");
07058                                        SUMA_RETURN(-1) ; } 
07059 
07060    fptr = fbuf ; nused = 0 ;
07061 
07062    /** scan for section strings, which start with "***" **/
07063    ngood = 0; /* assume none will be found */
07064    
07065    str[0] = '\0' ;  /* initialize string */
07066 
07067    if(LocalHead) { 
07068       fprintf(SUMA_STDERR,"Reading AFNI setup file = %s (%d bytes)",fname,nbuf) ;
07069    }
07070 
07071    while( nused < nbuf ){
07072 
07073       /**----------------------------------------**/
07074       /**-- skip ahead to next section keyword --**/
07075 
07076       SkipSection: while( ! SUMA_ISTARRED(str) ){ SUMA_GETSTR; SUMA_LH(str);}
07077 
07078       /*- 04 Jun 1999 -*/
07079 
07080       if( strcmp(str, "***COLORS") != 0 && strcmp(str, "***PALETTES") != 0){
07081          SUMA_GETSTR ;
07082          goto SkipSection ;
07083       }
07084 
07085       
07086       SS = SUMA_StringAppend (NULL, NULL);
07087       
07088       /**--------------------**/
07089       /**-- COLORS section --**/
07090 
07091       if( strcmp(str,"***COLORS") == 0 ){
07092          char label[SUMA_NSBUF] , defn[SUMA_NSBUF] ;
07093 
07094          if (LocalHead) fprintf (SUMA_STDERR,"%s: Found ***COLORS\n", FuncName);
07095          while(1){                          /* loop, looking for 'label = color' */
07096             SUMA_GETEQN ;
07097             
07098             if (LocalHead) {
07099                fprintf (SUMA_STDERR,"\t %s%s%s\n", left, middle, right);
07100             }
07101             
07102             
07103             
07104             if( !THD_filename_pure(left) ) continue ;
07105             /* don't allow 'none' to be redefined! */
07106             if( strcmp(left,"none")==0 || strcmp(right,"none")==0 ) {
07107                sprintf(left,"none");
07108                rgb[0] = rgb[1] = rgb[2] =-1.0;
07109             } else {
07110                if (!SUMA_Interpret_AFNIColor (right, rgb)) {
07111                   fprintf(SUMA_STDERR,"Error %s: Failed to interpret color %s\n", FuncName, right);
07112                   SUMA_RETURN(-1);
07113                }
07114             }
07115             SAC->Cv = SUMA_Add_Color (left, 
07116                            rgb[0], rgb[1], rgb[2], 1.0, 
07117                            SAC->Cv, &(SAC->N_cols));
07118          }
07119          continue ;  /* skip to end of outer while loop */   
07120       } /* end of COLORS */
07121 
07122       /**----------------------**/
07123       /**-- PALETTES section --**/
07124 
07125       if( strcmp(str,"***PALETTES") == 0 ){  /* loop, looking for palettes */
07126          char label[SUMA_NSBUF] = "NoThing" , ccc , * cpt ;
07127          PBAR_palette_array * ppar=NULL ;
07128          PBAR_palette ** ppp ;
07129          PBAR_palette  * ppnew ;
07130          int npane , pmode , icol=0 , jj ;
07131          float val ;
07132 
07133          if (LocalHead) fprintf (SUMA_STDERR,"enter ***PALETTES\n");
07134          
07135          /* loop, looking for palettes */
07136 
07137          while(1){
07138             SUMA_GETSTR ; if( SUMA_ISTARRED(str) ) goto SkipSection ;
07139             if( fptr-fbuf >= nbuf ){ if (fbuf) free(fbuf) ; fbuf = NULL; SUMA_RETURN(-1) ; }
07140 
07141             if( str[0] != '[' ){                     /* found a palette label */
07142                strcpy(label,str) ;
07143                if( !THD_filename_ok(label) ){
07144                   fprintf(SUMA_STDERR,"Error %s: In setup file %s, bad palette label: %s.\n Ignoring palette.\n",
07145                           FuncName, fname,label) ;
07146                   if (fbuf) free(fbuf) ; fbuf = NULL; 
07147                   SUMA_RETURN(-1) ;
07148                }
07149                
07150                if (LocalHead) {
07151                   fprintf (SUMA_STDERR,"%s: found palette label=%s. [len=%d label[0]=%d]\nnbuf=%d fptr-fbuf=%d\n", 
07152                      FuncName, label,(int)strlen(label),(int)label[0],
07153                      nbuf,fptr-fbuf);
07154                }
07155                
07156 
07157 
07158                SUMA_GETSTR ; if( SUMA_ISTARRED(str) ) goto SkipSection ;
07159             }
07160 
07161 
07162             if( str[0] != '[' ){                    /* bad news! */
07163                fprintf(SUMA_STDERR,"Error %s: In setup file %s, expected palette '[n]' here: %s.\n",
07164                               FuncName, fname , str ) ;
07165                SUMA_RETURN(-1) ;
07166             }
07167 
07168             /* decide how big the new palette is to be, and what mode  */
07169             ii = sscanf( str , "[%d%c" , &npane , &ccc ) ;
07170             if( ii < 2 ){
07171                fprintf(SUMA_STDERR,"%s: In setup file %s, can't interpret palette %s\n",
07172                               FuncName, fname , str ) ;
07173                SUMA_RETURN(-1) ;
07174             } else if( npane < NPANE_MIN || npane > NPANE_MAX ){
07175                fprintf(SUMA_STDERR,"%s: In setup file %s, illegal palette count %s.\n",
07176                               FuncName, fname , str ) ;
07177                SUMA_RETURN(-1) ;
07178             }
07179 
07180             /* at this point, now loop to read parameters for new palette */
07181             if (LocalHead) {
07182                fprintf(SUMA_STDERR,"%s: About to read %d panes.\n", FuncName, npane);
07183             }
07184             
07185             /* prepare the colormap */
07186             CM = (SUMA_COLOR_MAP *)SUMA_malloc(sizeof(SUMA_COLOR_MAP));
07187             if (CM == NULL) {
07188                SUMA_SL_Crit ("Failed to allocate for CM");
07189                SUMA_RETURN(-1);
07190             }
07191             CM->SO = NULL;
07192             CM->N_Col = npane;
07193             CM->cname = NULL;
07194  
07195             if (ccc == '+') CM->Sgn = 1;
07196             else CM->Sgn = -1;
07197             
07198             
07199             CM->Name = (char *)SUMA_calloc(strlen(label)+10, sizeof(char));
07200             CM->frac = (float *)SUMA_calloc(CM->N_Col, sizeof(float));
07201             CM->M = (float**)SUMA_allocate2D (CM->N_Col, 3, sizeof(float));
07202             if (  CM->frac == NULL || CM->M == NULL || CM->Name == NULL ) {
07203                SUMA_SL_Crit ("Failed to allocate for fields of CM.");
07204                SUMA_RETURN (-1);
07205             }
07206             if (CM->Sgn == 1) sprintf(CM->Name, "%s_p%d", label, CM->N_Col);
07207             else sprintf(CM->Name, "%s_n%d", label, CM->N_Col);
07208             
07209             for( ii=0 ; ii < npane ; ii++ ){
07210                SUMA_GETEQN ;
07211 
07212                if (LocalHead) {
07213                   fprintf(SUMA_STDERR,"%s: SUMA_GETEQN: %s %s %s\n",FuncName, left,middle,right) ;
07214                }
07215                
07216                /* find that color */
07217                icol = SUMA_Find_Color (right, SAC->Cv, SAC->N_cols);
07218                if (icol < 0) {
07219                   fprintf(SUMA_STDERR,"Error %s: Color %s not found in dbase.\nUsing no-color in its place\n", FuncName, right);
07220                   CM->M[npane - ii - 1][0] = CM->M[npane - ii - 1][1] = CM->M[npane - ii - 1][2] = -1.0; 
07221                } else {
07222                   CM->M[npane - ii - 1][0] = SAC->Cv[icol].r;
07223                   CM->M[npane - ii - 1][1] = SAC->Cv[icol].g;
07224                   CM->M[npane - ii - 1][2] = SAC->Cv[icol].b;
07225                }
07226                CM->frac[npane - ii - 1] = atof(left);
07227             }
07228             /* add the map to the list */
07229             SAC->CMv = SUMA_Add_ColorMap (CM, SAC->CMv, &(SAC->N_maps));  
07230             if (SAC->CMv) ++ngood;
07231             continue ;  /* to end of outer while */
07232          }
07233       } /* end of PALETTES */
07234       SUMA_GETSTR ; goto SkipSection ;             /* find another section */
07235 
07236    }  /* end of while loop */
07237    
07238    donesection:
07239 
07240    if (LocalHead) fprintf(SUMA_STDERR,"%s: Returning\n", FuncName);
07241    if (fbuf) free(fbuf) ; 
07242    SUMA_RETURN (ngood);
07243 
07244 }

SUMA_ASSEMBLE_LIST_STRUCT* SUMA_AssembleColorPlaneList SUMA_SurfaceObject   SO
 

Returns a list of the Colorplanes belonging to a certain surface.

Parameters:
SO  (SUMA_SurfaceObject *) pointer to surface object
Returns:
clist (SUMA_ASSEMBLE_LIST_STRUCT *) pointer to structure containing results
See also:
SUMA_FreeAssembleListStruct , SUMA_CreateAssembleListStruct

Definition at line 6390 of file SUMA_Color.c.

References SUMA_ASSEMBLE_LIST_STRUCT::clist, DListElmt_::data, dlist_destroy(), dlist_head, dlist_init(), dlist_ins_next(), dlist_ins_prev(), dlist_next, dlist_tail, i, SUMA_OVERLAYS::isBackGrnd, SUMA_OVERLAYS::Label, LocalHead, SUMA_ASSEMBLE_LIST_STRUCT::N_clist, SUMA_OVERLAYS::Name, DListElmt_::next, SUMA_ASSEMBLE_LIST_STRUCT::oplist, SUMA_OVERLAY_LIST_DATUM::Overlay, DList_::size, SUMA_Boolean, SUMA_calloc, SUMA_CreateAssembleListStruct(), SUMA_ENTRY, SUMA_free, SUMA_LH, SUMA_malloc, SUMA_MAX_NAME_LENGTH, SUMA_OverlaysToOrderedList(), and SUMA_RETURN.

Referenced by SUMA_RefreshDsetList().

06391 {
06392    static char FuncName[]={"SUMA_AssembleColorPlaneList"};
06393    int i=-1, N_clist=-1; 
06394    DList *list=NULL, *listop = NULL, *OverlayPlanelist = NULL;
06395    DListElmt *Elm = NULL, *Elmop = NULL, *Elm_OverlayPlanelist = NULL;
06396    char Label[SUMA_MAX_NAME_LENGTH], *store=NULL;
06397    char **clist=NULL;
06398    void **oplist=NULL;
06399    SUMA_ASSEMBLE_LIST_STRUCT *clist_str = NULL;
06400    SUMA_OVERLAY_LIST_DATUM *OvD=NULL, *oOvD=NULL;
06401    SUMA_Boolean SortByOrder = YUP;
06402    SUMA_Boolean Found = NOPE;
06403    SUMA_Boolean LocalHead = NOPE;
06404 
06405    SUMA_ENTRY;
06406    
06407    /* get list of all Overlay planes */
06408    OverlayPlanelist = SUMA_OverlaysToOrderedList (SO, 0);
06409 
06410    /* need a list to store new names */
06411    list = (DList *)SUMA_malloc(sizeof(DList));
06412    dlist_init(list, NULL); /* you don't want to free the strings */
06413    /* need a list to store the pointers, it is useless when SortByOrder is used, but I leave it in to keep the code simple */
06414    listop = (DList *)SUMA_malloc(sizeof(DList)); 
06415    dlist_init(listop, NULL); /* you don't want to free the data as it is copied from  OverlayPlanelist*/
06416          
06417    clist = NULL;
06418    N_clist = -1;
06419    Elm_OverlayPlanelist = NULL;
06420    do {
06421       if (!Elm_OverlayPlanelist) Elm_OverlayPlanelist = dlist_head(OverlayPlanelist);
06422       else Elm_OverlayPlanelist = Elm_OverlayPlanelist->next;
06423       
06424       OvD = (SUMA_OVERLAY_LIST_DATUM *) Elm_OverlayPlanelist->data;
06425 
06426       if (!OvD->Overlay->Label) sprintf (Label,"NULL");
06427       else sprintf (Label,"%s", OvD->Overlay->Label);
06428 
06429       SUMA_LH(Label);
06430       /* Now allocate space for that label */
06431       store = (char *)SUMA_calloc(strlen(Label)+10, sizeof(char));
06432       if (OvD->Overlay->isBackGrnd) {
06433          sprintf(store,"bk:%s", Label);
06434       } else {
06435          sprintf(store,"fg:%s", Label);
06436       }
06437 
06438       if (SortByOrder) {
06439          SUMA_LH("Sorting by order");
06440          /* list is already sorted, just copy the string and object structure pointers to lists */
06441          dlist_ins_next(list, dlist_tail(list), (void*)store);
06442          /* this line is redundant with SortByOrder but it don't hoyt */
06443          dlist_ins_next(listop, dlist_tail(listop), (void*)OvD);
06444       } else {   /* sort the list by aplhpabetical order */
06445          SUMA_LH("Sorting by name");
06446          if (!list->size) {
06447             dlist_ins_next(list, dlist_tail(list), (void*)store);
06448             dlist_ins_next(listop, dlist_tail(listop), (void*)OvD);
06449          }else { /* must sort first */
06450             Elm = NULL;
06451             Elmop = NULL;
06452             do {
06453                Found = NOPE;
06454                if (!Elm) {
06455                   Elm = dlist_head(list);
06456                   Elmop = dlist_head(listop);
06457                } else {
06458                   Elm = Elm->next;
06459                   Elmop = Elmop->next;
06460                }
06461 
06462                if (strcmp(store, (char*)Elm->data) <= 0) {
06463                   dlist_ins_prev(list, Elm, (void *)store);
06464                   dlist_ins_prev(listop, Elmop, (void *)OvD);
06465                   Found = YUP;
06466                } else if (Elm == dlist_tail(list)) {
06467                   /* reached the end, append */
06468                   dlist_ins_next(list, Elm, (void *)store);
06469                   dlist_ins_next(listop, Elmop, (void *)OvD);
06470                   Found = YUP;
06471                }
06472             } while (!Found);
06473          }
06474 
06475       }
06476    } while (Elm_OverlayPlanelist != dlist_tail(OverlayPlanelist));
06477    
06478    SUMA_LH("saving list.");
06479    if (!list->size) { /* Nothing found */
06480       SUMA_LH("Empty list");
06481       N_clist = 0;
06482    }else {
06483       Elm = NULL;
06484       Elmop = NULL;
06485       clist =  (char **)SUMA_calloc(list->size, sizeof(char *));
06486       oplist = (void **)SUMA_calloc(list->size, sizeof(void *));
06487       for (i=0; i< list->size; ++i) {
06488          if (!Elm) {
06489             Elm = dlist_head(list);
06490             Elmop = dlist_head(listop);
06491          } else {
06492             Elm = dlist_next(Elm);
06493             Elmop = dlist_next(Elmop);
06494          }
06495          clist[i] = (char*)Elm->data;
06496          OvD = (SUMA_OVERLAY_LIST_DATUM *) Elmop->data;
06497          oplist[i] = (void *)OvD->Overlay;
06498          if (LocalHead) fprintf (SUMA_STDERR,"%s: Inserting %s with %s (%s).\n", 
06499             FuncName, clist[i], OvD->Overlay->Label, OvD->Overlay->Name);
06500       }
06501 
06502       N_clist = list->size;
06503       /* destroy list */
06504       dlist_destroy(list);
06505       dlist_destroy(listop);
06506       dlist_destroy(OverlayPlanelist);
06507       SUMA_free(list);
06508       SUMA_free(listop);
06509       SUMA_free(OverlayPlanelist);
06510    }
06511    
06512    clist_str = SUMA_CreateAssembleListStruct();
06513    clist_str->clist = clist;
06514    clist_str->oplist = oplist;
06515    clist_str->N_clist = N_clist;
06516    
06517    /* return */
06518    SUMA_RETURN (clist_str);  
06519 }

SUMA_AFNI_COLORS* SUMA_Build_Color_maps void   
 

creates the colormaps available for SUMA

Definition at line 531 of file SUMA_Color.c.

References SUMA_AFNI_COLORS::CMv, i, SUMA_AFNI_COLORS::N_maps, SUMA_Add_ColorMap(), SUMA_CMAP_N_MAPS, SUMA_CMAP_UNDEFINED, SUMA_ENTRY, SUMA_Get_AFNI_Default_Color_Maps(), SUMA_GetStandardMap(), SUMA_RETURN, and SUMA_SL_Crit.

Referenced by SUMA_CmapOfPlane(), SUMA_CmapSelectList(), SUMA_ColorOverlayPlane_Info(), SUMA_CreateOverlayPointer(), SUMA_CreateUpdatableCmapMenu(), SUMA_LoadCmapFile(), SUMA_PrepAddmappableSO(), SUMA_ScaleToMap_Interactive(), and SUMA_SetConvexityPlaneDefaults().

00532 {
00533    static char FuncName[]={"SUMA_Build_Color_maps"};
00534    SUMA_RGB_NAME *Cv = NULL;
00535    int i;
00536    SUMA_COLOR_MAP **CMv=NULL;
00537    SUMA_COLOR_MAP *CM=NULL;
00538    SUMA_AFNI_COLORS *SAC=NULL;
00539    
00540    SUMA_ENTRY;
00541    
00542    SAC = SUMA_Get_AFNI_Default_Color_Maps();
00543   
00544    /* Now add SUMA's colormaps */
00545    
00546    for (i=SUMA_CMAP_UNDEFINED+1; i<SUMA_CMAP_N_MAPS; ++i) {
00547       CM = SUMA_GetStandardMap (i);
00548       if (!CM) {
00549          SUMA_SL_Crit("Failed to create standard maps");
00550          SUMA_RETURN(NULL);
00551       }
00552       SAC->CMv = SUMA_Add_ColorMap (CM, SAC->CMv, &(SAC->N_maps));
00553       if (!SAC->CMv) {
00554          SUMA_SL_Crit("Failed in SUMA_Add_ColorMap");
00555          SUMA_RETURN(NULL);
00556       }
00557    }
00558    
00559    SUMA_RETURN(SAC);
00560 }

SUMA_COLOR_MAP* SUMA_CmapOfPlane SUMA_OVERLAYS   Sover
 

Find the colormap associated with a colorplane.

Returns:
SUMA_COLOR_MAP * NULL if error or if cmap is explicit

Definition at line 1673 of file SUMA_Color.c.

References SUMA_OVERLAYS::cmapname, SUMA_AFNI_COLORS::CMv, SUMA_AFNI_COLORS::N_maps, SUMA_CommonFields::scm, SUMA_Build_Color_maps(), SUMA_ENTRY, SUMA_Find_ColorMap(), SUMA_RETURN, and SUMA_SL_Err.

Referenced by SUMA_cmap_wid_display(), and SUMA_cmap_wid_input().

01674 {
01675    static char FuncName[]={"SUMA_CmapOfPlane"};
01676    SUMA_COLOR_MAP *ColMap = NULL;
01677    int icmap;
01678    
01679    SUMA_ENTRY;
01680    
01681    if (!Sover) { SUMA_SL_Err("NULL Sover"); SUMA_RETURN(ColMap); }
01682    if (!Sover->cmapname) { SUMA_SL_Err("NULL Colormap name"); SUMA_RETURN(ColMap); }
01683    
01684    if (strcmp(Sover->cmapname, "explicit") == 0) {
01685       SUMA_RETURN(NULL);
01686    }
01687 
01688    if (!SUMAg_CF->scm) { 
01689       SUMAg_CF->scm = SUMA_Build_Color_maps();
01690       if (!SUMAg_CF->scm) { 
01691          SUMA_SL_Err("Can't build color maps"); 
01692          SUMA_RETURN(ColMap); 
01693       }
01694    }   
01695    icmap = SUMA_Find_ColorMap ( Sover->cmapname, SUMAg_CF->scm->CMv, SUMAg_CF->scm->N_maps, -2 );
01696    if (icmap < 0) { SUMA_SL_Err("Failed to find ColMap"); SUMA_RETURN(ColMap); }
01697    ColMap = SUMAg_CF->scm->CMv[icmap];
01698    
01699    SUMA_RETURN(ColMap);
01700    
01701 }

int SUMA_ColorizePlane SUMA_OVERLAYS   cp
 

colorize the data of the colorplane

Definition at line 7322 of file SUMA_Color.c.

References SUMA_OVERLAYS::cmapname, SUMA_OVERLAYS::ColVec, SUMA_OVERLAYS::DimFact, SUMA_DSET::dnel, SUMA_OVERLAYS::dset_link, i, LocalHead, SUMA_OVERLAYS::N_NodeDef, SUMA_OVERLAYS::NodeDef, SDSET_TYPE, SUMA_Boolean, SUMA_DsetInfo(), SUMA_ENTRY, SUMA_free, SUMA_GetDsetColIndex(), SUMA_LH, SUMA_NODE_B, SUMA_NODE_G, SUMA_NODE_INDEX, SUMA_NODE_R, SUMA_NODE_RGB, SUMA_RETURN, SUMA_S_Note, SUMA_ScaleToMap_Interactive(), SUMA_Show_ColorOverlayPlanes(), SUMA_SL_Err, NI_element::vec, and NI_element::vec_filled.

Referenced by SUMA_cb_AbsThresh_tb_toggled(), SUMA_cb_set_threshold(), SUMA_cb_SetCmapMode(), SUMA_cb_SetCoordBias(), SUMA_cb_ShowZero_tb_toggled(), SUMA_cb_SwitchBrightness(), SUMA_cb_SwitchIntensity(), SUMA_cb_SwitchThreshold(), SUMA_cb_SwithBrt_toggled(), SUMA_cb_SwithInt_toggled(), SUMA_cb_SwithThr_toggled(), SUMA_cb_SymIrange_tb_toggled(), SUMA_ColPlane_NewDimFact(), SUMA_InitRangeTable(), SUMA_iRGB_to_OverlayPointer(), SUMA_LoadDsetFile(), SUMA_PrepAddmappableSO(), SUMA_SetRangeTableTit_EV(), SUMA_SetRangeValue(), SUMA_SetScaleThr(), and SUMA_SwitchColPlaneCmap().

07323 {  
07324    static char FuncName[]={"SUMA_ColorizePlane"};
07325    int i, i3, N_i, *iv, *Nv;
07326    float *Rv, *Bv, *Gv;
07327    SUMA_Boolean LocalHead = NOPE;
07328    
07329    SUMA_ENTRY;
07330    
07331    if (LocalHead)  {
07332       SUMA_LH("Color Plane Pre Colorizing");
07333       SUMA_Show_ColorOverlayPlanes ( &cp, 1, 0);
07334    }
07335    if (!cp) { SUMA_SL_Err("NULL cp"); SUMA_RETURN(NOPE); }
07336    if (!cp->dset_link) { SUMA_SL_Err("Where's your dset_link?"); SUMA_RETURN(NOPE); }
07337    if (!cp->cmapname) { SUMA_SL_Err("Where's your cmapname?"); SUMA_RETURN(NOPE); }
07338    if (!cp->ColVec) { SUMA_SL_Err("NULL cV"); SUMA_RETURN(NOPE); }
07339    
07340    /* is the coloring direct ? */
07341    if (strcmp(cp->cmapname, "explicit") == 0) {
07342       
07343       SUMA_LH("Explicit color specification");
07344       /* make sure dataset is of type NODE_RGB */
07345       if (SDSET_TYPE(cp->dset_link) != SUMA_NODE_RGB) {
07346          SUMA_SL_Err("Direct mapping is only supported for SUMA_NODE_RGB types");
07347          SUMA_RETURN(NOPE);
07348       }
07349       iv = SUMA_GetDsetColIndex (cp->dset_link, SUMA_NODE_INDEX, &N_i);
07350       if (N_i != 1) { SUMA_SL_Err("Failed to find index column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
07351       Nv = (int *)cp->dset_link->dnel->vec[iv[0]]; SUMA_free(iv); iv = NULL;
07352       iv = SUMA_GetDsetColIndex (cp->dset_link, SUMA_NODE_R, &N_i);
07353       if (N_i != 1) { SUMA_SL_Err("Failed to find red column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
07354       Rv = (float *)cp->dset_link->dnel->vec[iv[0]];SUMA_free(iv); iv = NULL;
07355       iv = SUMA_GetDsetColIndex (cp->dset_link, SUMA_NODE_G, &N_i);
07356       if (N_i != 1) { SUMA_SL_Err("Failed to find green column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
07357       Gv = (float *)cp->dset_link->dnel->vec[iv[0]];SUMA_free(iv); iv = NULL;
07358       iv = SUMA_GetDsetColIndex (cp->dset_link, SUMA_NODE_B, &N_i);
07359       if (N_i != 1) { SUMA_SL_Err("Failed to find blue column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
07360       Bv = (float *)cp->dset_link->dnel->vec[iv[0]];SUMA_free(iv); iv = NULL;
07361       /* go ahead and populate cV */
07362       
07363       if (LocalHead) {
07364          char *s = NULL;
07365          s = SUMA_DsetInfo(cp->dset_link, 0);
07366          SUMA_S_Note(s);
07367          SUMA_free(s);
07368       }
07369       
07370       if (cp->DimFact == 1.0) {
07371          for (i=0; i < cp->dset_link->dnel->vec_filled; ++i) {
07372             i3 = 3 * i;
07373             cp->NodeDef[i] = Nv[i];
07374             cp->ColVec[i3] = Rv[i]; ++i3;
07375             cp->ColVec[i3] = Gv[i]; ++i3;
07376             cp->ColVec[i3] = Bv[i]; 
07377          } 
07378       } else {
07379          for (i=0; i < cp->dset_link->dnel->vec_filled; ++i) {   
07380             i3 = 3 * i;
07381             cp->NodeDef[i] = Nv[i];
07382             cp->ColVec[i3] = Rv[i] * cp->DimFact; ++i3;
07383             cp->ColVec[i3] = Gv[i] * cp->DimFact; ++i3;
07384             cp->ColVec[i3] = Bv[i] * cp->DimFact; 
07385          }
07386       }
07387       cp->N_NodeDef = cp->dset_link->dnel->vec_filled;
07388    } else {
07389       /* indirect mapping */
07390       if (!SUMA_ScaleToMap_Interactive (cp)) {
07391          SUMA_SL_Err("Failed in SUMA_ScaleToMap_Interactive.");
07392          SUMA_RETURN(0); 
07393       }
07394       /* cp->N_NodeDef is taken care of inside SUMA_ScaleToMap_Interactive */
07395    }   
07396    
07397    
07398    
07399    if (LocalHead)  {
07400       SUMA_LH("Color Plane Post Colorizing");
07401       SUMA_Show_ColorOverlayPlanes ( &cp, 1, 0);
07402    }
07403    SUMA_RETURN(1);
07404 }

char* SUMA_ColorMapVec_Info SUMA_COLOR_MAP **    CMv,
int    N_maps,
int    detail
 

List the colormaps in the vector.

Parameters:
CMv  (SUMA_COLOR_MAP **) an array of pointers to colormap structures
N_maps  (int) the number of colormaps in CMv
detail  (int) 0, just the name of the colormaps 1, up to 5 of the colors listed 2, complete colormap listed
See also:
char *SUMA_Show_ColorMapVec

Definition at line 786 of file SUMA_Color.c.

References i, LocalHead, SUMA_STRING::s, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_LH, SUMA_RETURN, SUMA_SL_Err, and SUMA_StringAppend().

Referenced by SUMA_ColorOverlayPlane_Info(), SUMA_help_Cmap_message_Info(), and SUMA_Show_ColorMapVec().

00787 {
00788    static char FuncName[]={"SUMA_ColorMapVec_Info"};
00789    int i, j, jmax;
00790    char stmp[256], *s = NULL;
00791    SUMA_STRING *SS = NULL;  
00792    SUMA_Boolean LocalHead = NOPE;
00793    
00794    SUMA_ENTRY;
00795    
00796    SUMA_LH("Entered");
00797    SS = SUMA_StringAppend (NULL, NULL);
00798    
00799    if (CMv) {
00800       for (i=0; i < N_maps; ++i) {
00801          if (!CMv[i]) {
00802             sprintf (stmp, "%d/%d: cmap(%d) NULL\n", i+1, N_maps, i);
00803             SS = SUMA_StringAppend (SS, stmp);
00804          } else {
00805             switch (CMv[i]->Sgn) {
00806                case 0:
00807                   sprintf (stmp, "%d/%d: cmap(%d) %s(.), %d cols.", i+1, N_maps, i, CMv[i]->Name,  CMv[i]->N_Col);
00808                   break;
00809                case 1:
00810                   sprintf (stmp, "%d/%d: cmap(%d) %s(+), %d cols.", i+1, N_maps, i, CMv[i]->Name,  CMv[i]->N_Col);
00811                   break;
00812                case -1:
00813                   sprintf (stmp, "%d/%d: cmap(%d) %s(-), %d cols.", i+1, N_maps, i, CMv[i]->Name,  CMv[i]->N_Col);
00814                   break;
00815                default:   
00816                   sprintf (stmp, "%d/%d: cmap(%d) %s(?), %d cols.\n\tSgn field of colormap is not acceptable (%d)\n", 
00817                      i+1, N_maps, i, CMv[i]->Name,  CMv[i]->N_Col, CMv[i]->Sgn);
00818                   break;
00819             }
00820             SS = SUMA_StringAppend (SS, stmp);
00821             if (CMv[i]->frac) {
00822                SS = SUMA_StringAppend (SS, "   Possibly non-linear\n");
00823             } else {
00824                SS = SUMA_StringAppend (SS, "   Linear\n");
00825             }
00826             switch (detail) {
00827                case 0:
00828                   jmax = 0;
00829                   break;
00830                case 1:
00831                   if (CMv[i]->N_Col < 5) jmax = CMv[i]->N_Col;
00832                   else jmax = 5;
00833                   break;
00834                case 2:
00835                   jmax = CMv[i]->N_Col;
00836                   break;
00837                default:
00838                   SUMA_SL_Err("Bad detail value\nUsing detail = 2");
00839                   jmax = CMv[i]->N_Col;
00840                   break;
00841             }
00842             
00843             if (jmax) {
00844                for (j=jmax-1; j >= 0; --j) {
00845                   if (CMv[i]->frac) {
00846                      if (j == jmax -1) {
00847                         sprintf (stmp, "rank (i)[R    \tG    \tB    \t\tf]\n");
00848                         SS = SUMA_StringAppend (SS,stmp);    
00849                      }
00850                      sprintf (stmp, "%03d:\t[% .3f\t% .3f\t% .3f\t\t% .3f]\n", 
00851                                     j, CMv[i]->M[j][0], CMv[i]->M[j][1],  CMv[i]->M[j][2], CMv[i]->frac[j]);
00852                   } else {
00853                      if (j == jmax - 1) {
00854                         sprintf (stmp, "rank (i):[R    \tG    \tB    ]\n");
00855                         SS = SUMA_StringAppend (SS,stmp);    
00856                      }
00857                      sprintf (stmp, "%03d:\t[% .3f\t% .3f\t% .3f]\n", 
00858                                     j, CMv[i]->M[j][0], CMv[i]->M[j][1],  CMv[i]->M[j][2]);
00859                   }
00860                   SS = SUMA_StringAppend (SS,stmp); 
00861                }
00862                if (jmax < CMv[i]->N_Col - 1) { 
00863                   if (CMv[i]->frac) SS = SUMA_StringAppend (SS,"..:\t [.....\t....\t....\t\t....]\n");
00864                   else SS = SUMA_StringAppend (SS,"..:\t [.....\t....\t....]\n");
00865                }
00866                if (jmax < CMv[i]->N_Col) { 
00867                   j = CMv[i]->N_Col - 1;
00868                   if (CMv[i]->frac) {
00869                      sprintf (stmp, "%03d:\t [% .3f\t% .3f\t% .3f\t\t% .3f]\n", 
00870                                     j, CMv[i]->M[j][0], CMv[i]->M[j][1],  CMv[i]->M[j][2], CMv[i]->frac[j]);
00871                   } else {
00872                      sprintf (stmp, "%03d:\t [% .3f\t% .3f\t% .3f]\n", 
00873                                     j, CMv[i]->M[j][0], CMv[i]->M[j][1],  CMv[i]->M[j][2]);
00874                   }
00875                   SS = SUMA_StringAppend (SS,stmp); 
00876                }
00877             }
00878          }
00879       }
00880    } else {
00881       sprintf (stmp, "NULL CMv.\n");
00882       SS = SUMA_StringAppend (SS, stmp);
00883    }   
00884    
00885    /* clean SS */
00886    SS = SUMA_StringAppend (SS, NULL);
00887    /* copy s pointer and free SS */
00888    s = SS->s;
00889    SUMA_free(SS); 
00890   
00891    SUMA_LH("Left");
00892       
00893    SUMA_RETURN(s);
00894 }

char* SUMA_ColorOverlayPlane_Info SUMA_OVERLAYS **    Overlays,
int    N_Overlays,
int    detail
 

Shows the contents of the color overlay planes.

See also:
SUMA_Show_ColorOverlayPlanes (for backward compat.)

Definition at line 5325 of file SUMA_Color.c.

References SUMA_AFNI_COLORS::CMv, COLP_N_ALLOC, COLP_N_NODEDEF, COLP_NODEDEF, i, SUMA_AFNI_COLORS::N_maps, SUMA_STRING::s, s2, SUMA_CommonFields::scm, SUMA_Build_Color_maps(), SUMA_ColorMapVec_Info(), SUMA_ENTRY, SUMA_Find_ColorMap(), SUMA_free, SUMA_RETURN, SUMA_ScaleToMapOpt_Info(), SUMA_StringAppend(), and SUMA_StringAppend_va().

Referenced by SUMA_Show_ColorOverlayPlanes(), and SUMA_SurfaceObject_Info().

05326 {
05327    static char FuncName[]={"SUMA_ColorOverlayPlane_Info"};
05328    char stmp[1000], *s = NULL, *s2 = NULL;
05329    int i, j, ShowN, icmap;
05330    SUMA_COLOR_MAP *ColMap=NULL;
05331    int N_Alloc = -1, *NodeDef=NULL, N_NodeDef = -1;
05332 
05333    SUMA_STRING *SS = NULL;
05334    
05335    SUMA_ENTRY; 
05336    
05337    SS = SUMA_StringAppend (NULL, NULL);
05338    
05339    sprintf (stmp,"Info on %d color overlay planes:\n---------------------------------\n", N_Overlays);
05340    SS = SUMA_StringAppend (SS,stmp);
05341    for (i=0; i < N_Overlays; ++i) {
05342       if (Overlays[i]) {
05343          sprintf (stmp,"Overlay plane %s:\norder %d, indexed %d\nDimFact %f, global opacity %f, isBackGrnd (isBackground) %d.\n ForceIntRange %f, %f.\nSymIrange = %d\n", 
05344             Overlays[i]->Name, Overlays[i]->PlaneOrder, i, Overlays[i]->DimFact, Overlays[i]->GlobalOpacity, Overlays[i]->isBackGrnd, 
05345             Overlays[i]->ForceIntRange[0], Overlays[i]->ForceIntRange[1], Overlays[i]->SymIrange);
05346          SS = SUMA_StringAppend (SS,stmp);
05347          SS = SUMA_StringAppend_va (SS, "N_links = %d\n", Overlays[i]->N_links);
05348          SS = SUMA_StringAppend_va (SS, "LinkedPtrType = %d\n", Overlays[i]->LinkedPtrType);
05349          SS = SUMA_StringAppend_va (SS, "owner_id = %s\n",  Overlays[i]->owner_id);
05350          NodeDef = COLP_NODEDEF(Overlays[i]);
05351          N_NodeDef = COLP_N_NODEDEF(Overlays[i]);
05352          N_Alloc = COLP_N_ALLOC(Overlays[i]);
05353          sprintf (stmp,"Show=%d, N_Alloc=%d, N_NodeDef=%d\n", (int)Overlays[i]->Show, N_Alloc, N_NodeDef);
05354          SS = SUMA_StringAppend (SS,stmp);
05355          if (detail > 1) {
05356             ShowN = N_NodeDef;
05357          } else { 
05358             if (N_NodeDef > 5) ShowN = 5;
05359             else ShowN = N_NodeDef;
05360          }
05361          SS = SUMA_StringAppend (SS,"\n");
05362          sprintf (stmp,"\tindex\tR\tG\tB\tLocOp\n");
05363          SS = SUMA_StringAppend (SS,stmp);
05364          for (j=0; j < ShowN; ++j) {
05365             SS = SUMA_StringAppend_va (SS, "\t%d\t%.3f\t%.3f\t%.3f\t%.3f\n", 
05366                      NodeDef[j], Overlays[i]->ColVec[3*j], 
05367                      Overlays[i]->ColVec[3*j+1], Overlays[i]->ColVec[3*j+2],
05368                      Overlays[i]->LocalOpacity[j]);
05369          }
05370          SS = SUMA_StringAppend (SS,"\n");
05371          if (!Overlays[i]->cmapname) SS = SUMA_StringAppend (SS,"cmapname = NULL\n");
05372          else SS = SUMA_StringAppend_va (SS,"cmapname = %s\n", Overlays[i]->cmapname);
05373          /* get the color map */
05374          if (!SUMAg_CF->scm) { /* try creating since it is no longer created at initialization */
05375             static int try_once=0;
05376             if (!try_once) { SUMAg_CF->scm = SUMA_Build_Color_maps(); ++ try_once; }
05377          }
05378          if (SUMAg_CF->scm) {
05379             icmap = SUMA_Find_ColorMap ( Overlays[i]->cmapname, SUMAg_CF->scm->CMv, SUMAg_CF->scm->N_maps, -2 );
05380             if (icmap < 0) { SS = SUMA_StringAppend (SS,"cmap not found.\n"); }
05381             else {
05382                ColMap = SUMAg_CF->scm->CMv[icmap];
05383                s2 = SUMA_ColorMapVec_Info(&ColMap, 1, detail);
05384                SS = SUMA_StringAppend (SS, s2); SUMA_free(s2); s2 = NULL;
05385             }   
05386             s2 = SUMA_ScaleToMapOpt_Info (Overlays[i]->OptScl, 0);
05387             SS = SUMA_StringAppend (SS, s2); SUMA_free(s2); s2 = NULL;
05388          } else {
05389             SS = SUMA_StringAppend (SS,"\tNULL SUMA color maps.\n");
05390          }
05391       } else {
05392          SS = SUMA_StringAppend (SS,"\tNULL overlay plane.\n");
05393       }
05394    }
05395    /* clean SS */
05396    SS = SUMA_StringAppend (SS, NULL);
05397    /* copy s pointer and free SS */
05398    s = SS->s;
05399    SUMA_free(SS); 
05400    
05401    SUMA_RETURN(s);
05402 }

char* SUMA_ColorVec_Info SUMA_RGB_NAME   Cv,
int    N_cols
 

List the colors in the vector.

See also:
char *SUMA_Show_ColorVec

Definition at line 736 of file SUMA_Color.c.

References a, i, LocalHead, r, SUMA_STRING::s, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_RETURN, and SUMA_StringAppend().

Referenced by SUMA_Show_ColorVec().

00737 {
00738    static char FuncName[]={"SUMA_ColorVec_Info"};
00739    int i;
00740    char stmp[100], *s = NULL;
00741    SUMA_STRING *SS = NULL;  
00742    SUMA_Boolean LocalHead = NOPE;
00743    
00744    SUMA_ENTRY;
00745    
00746    SS = SUMA_StringAppend (NULL, NULL);
00747    
00748    if (Cv) {
00749       for (i=0; i < N_cols; ++i) {
00750          if (Cv[i].r == -1) {
00751             sprintf (stmp, "%d/%d: color(%d) No Color(%s): [%f %f %f %f]\n", 
00752                            i+1, N_cols, i, Cv[i].Name, Cv[i].r, Cv[i].g, Cv[i].b, Cv[i].a);
00753             SS = SUMA_StringAppend (SS, stmp);
00754          } else {
00755             sprintf (stmp, "%d/%d: color(%d) %s: [%f %f %f %f]\n", 
00756                            i+1, N_cols, i, Cv[i].Name, Cv[i].r, Cv[i].g, Cv[i].b, Cv[i].a);
00757             SS = SUMA_StringAppend (SS, stmp);
00758          }
00759       }
00760    } else {
00761       sprintf (stmp, "NULL Cv.\n");
00762       SS = SUMA_StringAppend (SS, stmp);
00763    }   
00764    
00765    /* clean SS */
00766    SS = SUMA_StringAppend (SS, NULL);
00767    /* copy s pointer and free SS */
00768    s = SS->s;
00769    SUMA_free(SS); 
00770       
00771    SUMA_RETURN(s);
00772 }

SUMA_Boolean SUMA_CompactOverlaysOrder SUMA_SurfaceObject   SO
 

SUMA_COLOR_SCALED_VECT* SUMA_Create_ColorScaledVect int    N_Node
 

function to allocate and initialize a structure of the type SUMA_COLOR_SCALED_VECT S = SUMA_Create_ColorScaledVect();

Parameters:
N_Node  (int) number of nodes for which colors will be assigned \ret S (SUMA_COLOR_SCALED_VECT * ) pointer to structure that will contain the color map of N_Node nodes

Definition at line 2933 of file SUMA_Color.c.

References SUMA_COLOR_SCALED_VECT::BiasCoordVec, SUMA_COLOR_SCALED_VECT::cV, SUMA_COLOR_SCALED_VECT::isMasked, LocalHead, SUMA_COLOR_SCALED_VECT::N_Node, S, SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_free, SUMA_malloc, and SUMA_RETURN.

Referenced by main(), SUMA_input(), SUMA_NodeVal2irgba_nel(), SUMA_ScaleToMap_Interactive(), and SUMA_SphereQuality().

02934 {
02935    static char FuncName[]={"SUMA_Create_ColorScaledVect"};
02936    SUMA_COLOR_SCALED_VECT * S;
02937    SUMA_Boolean LocalHead = NOPE;
02938    
02939    SUMA_ENTRY;
02940    if (LocalHead) fprintf (SUMA_STDERR,"%s:\n Allocate for %d nodes ...\n", FuncName, N_Node);
02941    S = (SUMA_COLOR_SCALED_VECT *)SUMA_malloc(sizeof(SUMA_COLOR_SCALED_VECT));
02942    if (S == NULL) {
02943       fprintf(SUMA_STDERR, "Error %s: Failed to allocate for S.\n", FuncName);
02944       SUMA_RETURN (S);
02945    }
02946    
02947    /* S->cM = (float **) SUMA_allocate2D(N_Node, 3, sizeof(float));  */
02948    S->cV = (float *) SUMA_calloc(N_Node * 3, sizeof(float));
02949    S->isMasked = (SUMA_Boolean *)SUMA_calloc(N_Node, sizeof(SUMA_Boolean));
02950    S->BiasCoordVec = NULL; /* That is created in the scaleToMap functions if needed */
02951    
02952    if (!S->cV || !S->isMasked) {
02953       fprintf(SUMA_STDERR, "Error %s: Failed to allocate for S->cV or S->isMasked.\n", FuncName);
02954       SUMA_free(S); S = NULL;
02955       SUMA_RETURN (S);
02956    }
02957    
02958    S->N_Node = N_Node;
02959    
02960    
02961    SUMA_RETURN(S);
02962 }

SUMA_OVERLAYS* SUMA_CreateOverlayPointer int    N_Nodes,
const char *    Name,
SUMA_DSET   dset,
char *    ownerid
 

Function to allocate and initialize an Overlays pointer

ans = SUMA_CreateOverlayPointer (N_Nodes, Name, SUMA_DSET *dset, char *ownerid);

Parameters:
N_Nodes  (int): The number of nodes for which color is assigned
Name  (char *): A character string containing the name of the color overlay
dset  (SUMA_DSET *): Pointer to data set structure that this plane gets its data from.
ownerid  (char *) idcode of owner of colorplane. Can set it to NULL if you don't care. \ret ans (SUMA_OVERLAYS *): a pointer to the structure containing the color overlay NULL is returned in case of trouble.
The following fields are set to these defaults: Show = NOPE; GlobalOpacity = -1.0; LocalOpacity vector is all zeros except the first value is -1.0 FullList = 1 PlaneOrder = -1; i.e. not set isBackGrnd = 0 ; i.e. none SymIrange = 0;
See also:
SUMA_FreeOverlayPointer

Definition at line 4593 of file SUMA_Color.c.

References SUMA_OVERLAYS::cmapname, COLP_N_ALLOC, SUMA_OVERLAYS::ColVec, SUMA_OVERLAYS::DimFact, SUMA_DSET::dnel, SUMA_OVERLAYS::dset_link, SUMA_FileName::FileName, SUMA_OVERLAYS::ForceIntRange, SUMA_OVERLAYS::FullList, SUMA_OVERLAYS::GlobalOpacity, i, SUMA_OVERLAYS::isBackGrnd, SUMA_OVERLAYS::Label, SUMA_OVERLAYS::LinkedPtrType, LocalHead, SUMA_OVERLAYS::LocalOpacity, SUMA_OVERLAYS::N_links, SUMA_OVERLAYS::N_NodeDef, SUMA_OVERLAYS::Name, SUMA_OVERLAYS::NodeDef, SUMA_OVERLAYS::OptScl, SUMA_OVERLAYS::owner_id, SUMA_FileName::Path, SUMA_OVERLAYS::PlaneOrder, SUMA_CommonFields::scm, SUMA_OVERLAYS::Show, SUMA_Boolean, SUMA_Build_Color_maps(), SUMA_calloc, SUMA_copy_string(), SUMA_ENTRY, SUMA_free, SUMA_LH, SUMA_LINKED_OVERLAY_TYPE, SUMA_LinkToPointer(), SUMA_malloc, SUMA_RETURN, SUMA_ScaleToMapOptInit(), SUMA_SL_Err, SUMA_StripPath(), SUMA_OVERLAYS::SymIrange, and NI_element::vec_len.

Referenced by SUMA_iRGB_to_OverlayPointer(), SUMA_LoadDsetFile(), and SUMA_PrepAddmappableSO().

04594 {
04595    static char FuncName[]={"SUMA_CreateOverlayPointer"};
04596    SUMA_OVERLAYS *Sover=NULL;
04597    SUMA_FileName sfn;
04598    int N_Alloc = -1, i=0;
04599    SUMA_Boolean LocalHead = NOPE;
04600    
04601    SUMA_ENTRY;
04602 
04603    if (!dset) {
04604       SUMA_SL_Err("Need dset");
04605       SUMA_RETURN(NULL);
04606    }
04607    
04608    Sover = (SUMA_OVERLAYS *)SUMA_malloc(sizeof(SUMA_OVERLAYS));
04609    if (!Sover) {
04610       fprintf (SUMA_STDERR,"Error %s: Could not allocate for Sover.\n", FuncName);
04611       SUMA_RETURN (NULL);
04612    }
04613    
04614    Sover->N_links = 0;
04615    if (ownerid) sprintf(Sover->owner_id, "%s", ownerid);
04616    else Sover->owner_id[0] = '\0';
04617    Sover->LinkedPtrType = SUMA_LINKED_OVERLAY_TYPE;
04618    
04619    /* make a link to dset */
04620    SUMA_LH("Linking to Dset");
04621    Sover->dset_link = (SUMA_DSET *)SUMA_LinkToPointer ((void *)dset);
04622    /* N_Nodes is no longer used, use it for sanity check only */
04623    if (Sover->dset_link->dnel) {
04624       if (N_Nodes != Sover->dset_link->dnel->vec_len) {
04625          SUMA_SL_Err("N_Nodes not equal to vec_len.");
04626          SUMA_RETURN(NULL);
04627       }
04628   } else { SUMA_SL_Err ("No nel yet !"); SUMA_RETURN(NULL);}
04629    
04630    /* copy the name */
04631    Sover->Name = (char *)SUMA_calloc (strlen(Name)+1, sizeof(char));
04632    Sover->Name = strcpy(Sover->Name, Name);
04633    
04634    /* create a label */
04635    sfn = SUMA_StripPath((char *)Name);
04636    Sover->Label = sfn.FileName;
04637    if (sfn.Path) SUMA_free(sfn.Path); /* get rid of path */
04638    
04639    
04640    /* not here anymore */
04641    SUMA_LH("Allocating for vectors");
04642    N_Alloc = COLP_N_ALLOC(Sover);
04643    
04644    if (N_Alloc != N_Nodes) {
04645       SUMA_SL_Err("This is not supposed to be.");
04646       SUMA_RETURN(NULL);
04647    }
04648    Sover->N_NodeDef = N_Nodes;
04649    Sover->NodeDef = (int *) SUMA_calloc(N_Alloc, sizeof(int));
04650    for (i=0; i < Sover->N_NodeDef; ++i) Sover->NodeDef[i] = i;
04651    Sover->FullList = 1;
04652    
04653    /* Sover->ColMat = (float **) SUMA_allocate2D(Sover->N_Alloc, 3, sizeof(float)); NO MORE 2D ! Mar 17 04*/
04654    Sover->ColVec = (float *)SUMA_calloc(N_Alloc*3, sizeof(float));
04655    Sover->LocalOpacity = (float *)SUMA_calloc(N_Alloc, sizeof(float));
04656    
04657    if (!Sover->ColVec || !Sover->LocalOpacity || !Sover->NodeDef) {
04658       fprintf (SUMA_STDERR,"Error %s: Could not allocate for Sover fields.\n", FuncName);
04659       SUMA_free(Sover);
04660       SUMA_RETURN (NULL);   
04661    }
04662    
04663    Sover->GlobalOpacity = -1.0; /* no factor applied */
04664    Sover->LocalOpacity[0] = -1.0; /* flag indicating local facts have not been initialized */
04665    Sover->Show = NOPE;
04666    Sover->PlaneOrder = -1; /* No order is specified */
04667    Sover->isBackGrnd = 0; /* no brightness modulation effects */
04668    Sover->DimFact = 0.3;
04669    Sover->ForceIntRange[0] = 0.0; Sover->ForceIntRange[1] = 0.0; /* force nothing */
04670    
04671    /* new, from Feb 20 */
04672    /* default, choose something */
04673    SUMA_LH("SCM stuff");
04674    if (!SUMAg_CF->scm) {  /* try building it */ 
04675       SUMAg_CF->scm = SUMA_Build_Color_maps();
04676    }
04677    if (!SUMAg_CF->scm) {
04678       SUMA_LH("SUMA color maps not set up.");
04679       Sover->cmapname = NULL;
04680       Sover->OptScl = NULL;
04681    } else {
04682       Sover->cmapname = SUMA_copy_string("bgyr64");
04683       Sover->OptScl = SUMA_ScaleToMapOptInit();
04684       if (!Sover->OptScl) {
04685          fprintf (SUMA_STDERR,"Error %s: Could not get scaling option structure.\n", FuncName);
04686          SUMA_RETURN (NOPE); 
04687       }
04688    }
04689    
04690    Sover->SymIrange = 0;
04691    
04692    SUMA_RETURN (Sover);
04693 }

SUMA_AFNI_COLORS* SUMA_DestroyAfniColors SUMA_AFNI_COLORS   SAC
 

Cleans up and destroys the contents of the SUMA_AFNI_COLORS.

See also:
SUMA_Get_AFNI_Default_Color_Maps

Definition at line 708 of file SUMA_Color.c.

References SUMA_AFNI_COLORS::CMv, SUMA_AFNI_COLORS::Cv, i, SUMA_AFNI_COLORS::N_cols, SUMA_AFNI_COLORS::N_maps, SUMA_free, SUMA_Free_ColorMap(), and SUMA_RETURN.

Referenced by SUMA_Free_CommonFields().

00709 {
00710    static char FuncName[]={"SUMA_DestroyAfniColors"};
00711    int i;
00712    
00713    if (!SAC) SUMA_RETURN(NULL);
00714    
00715    /* Now clean the colormap vector */
00716    for (i=0; i < SAC->N_maps; ++i) {
00717       if (SAC->CMv[i]) SUMA_Free_ColorMap(SAC->CMv[i]);
00718    }
00719    SUMA_free(SAC->CMv);
00720    SAC->N_maps = -1;
00721    
00722    /* Now clean the color vector */
00723    SUMA_free(SAC->Cv);
00724    SAC->N_cols = -1;
00725    
00726    /* Now destroy SAC */
00727    SUMA_free(SAC);
00728    
00729    SUMA_RETURN(NULL);
00730 }

double* SUMA_dPercRange double *    V,
double *    Vsort,
int    N_V,
double *    PercRange,
double *    PercRangeVal,
int *    iPercRangeVal
 

Vsort = SUMA_dPercRange (V, Vsort, N_V, PercRange, PercRangeVal, iPercRangeVal) the double version of SUMA_PercRange, working with double instead of float data

See also:
SUMA_PercRange

Definition at line 4529 of file SUMA_Color.c.

References SUMA_calloc, SUMA_COPY_VEC, SUMA_ENTRY, SUMA_free, SUMA_RETURN, and SUMA_z_doubqsort().

Referenced by SUMA_LoadPrepInVol().

04530 {
04531    static char FuncName[] = {"SUMA_dPercRange"};
04532    int *isort, il, ih;
04533    
04534    SUMA_ENTRY;
04535 
04536    if (PercRange[0] < 0 || PercRange[0] > 100 || PercRange[1] < 0 || PercRange[1] > 100) {
04537       fprintf (SUMA_STDERR, "Error %s: Values in PercRange must be between 0 and 100.\nVsort will be freed.\n", FuncName);
04538       if (Vsort) SUMA_free(Vsort);
04539       SUMA_RETURN (NULL);
04540    }
04541     
04542    if (!Vsort) {
04543       /* need to create my own sorted version */
04544         Vsort = (double *)SUMA_calloc (N_V, sizeof(double));
04545       if (!Vsort) {
04546          fprintf (SUMA_STDERR, "Error %s: Failed to allocate for Vsort.\n", FuncName);
04547          SUMA_RETURN (NULL);
04548       }
04549       /* copy V to Vsort */
04550       SUMA_COPY_VEC (V, Vsort, N_V, double, double);
04551       
04552       /* sort Vsort */
04553       isort = SUMA_z_doubqsort (Vsort  , N_V ); SUMA_free(isort);
04554    } 
04555    
04556    /* choose the index for the lower range */
04557    il = (int)rint((N_V-1)*PercRange[0]/100.0);
04558    ih = (int)rint((N_V-1)*PercRange[1]/100.0);
04559    PercRangeVal[0] = Vsort[il];
04560    PercRangeVal[1] = Vsort[ih];
04561    if (iPercRangeVal) { 
04562       iPercRangeVal[0] = il; iPercRangeVal[1] = ih;
04563    }
04564    SUMA_RETURN (Vsort);
04565 }

SUMA_OVERLAYS* SUMA_Fetch_OverlayPointer SUMA_OVERLAYS **    Overlays,
int    N_Overlays,
const char *    Name,
int *    OverInd
 

function to fetch a certain overlay pointer ptr = SUMA_Fetch_OverlayPointer (Overlays, N_Overlays, Name, OverInd);

if an overlay pointer of the name Name exists in SO then it is returned in ptr else ptr is null

Parameters:
Overlays  (SUMA_OVERLAYS **) vector of overlay plane pointers
N_Overlays  (int) number of overlay planes
Name  (const char *) name of overlay plane to fetch
OverInd  (int *) index of overlay plane in Overlays that is fetched (-1 if plane not found) \ret ptr (SUMA_OVERLAYS *) pointer of overlay plane (= Overlays[*OverInd]) NULL if Name is not found

Definition at line 4772 of file SUMA_Color.c.

References i, LocalHead, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_AddNewPlane(), SUMA_FlushPlaneNotInUse(), SUMA_GetOverlaysFromParent(), SUMA_iRGB_to_OverlayPointer(), SUMA_MovePlaneDown(), SUMA_MovePlaneUp(), and SUMA_SetConvexityPlaneDefaults().

04773 {
04774    static char FuncName[]={"SUMA_Fetch_OverlayPointer"};
04775    int i;
04776    SUMA_OVERLAYS *ptr= NULL;
04777    SUMA_Boolean LocalHead = NOPE;
04778    
04779    SUMA_ENTRY;
04780 
04781    for (i=0; i < N_Overlays; ++i) {
04782       if (!strcmp(Overlays[i]->Name, Name)) {
04783          *OverInd = i;
04784          if (LocalHead) fprintf (SUMA_STDOUT,"%s: Found overlay plane %s, indexed %d.\n", FuncName, Name, i);
04785          SUMA_RETURN (Overlays[i]);
04786       }
04787    }
04788    
04789    if (LocalHead) fprintf (SUMA_STDOUT,"%s: Overlay plane %s was not found.\n", FuncName, Name);
04790    
04791    *OverInd = -1;
04792 
04793    SUMA_RETURN (NULL);
04794 } 

int SUMA_Find_Color char *    Name,
SUMA_RGB_NAME   Cv,
int    N_cols
 

Locate a color in the color vector.

Parameters:
Name  (char *) Name ('\0' terminated) name of color to be found
Cv  (SUMA_RGB_NAME *) vector of color structs to be searched
N_cols  (int) number of colors in Cv
Returns:
icol (int) the index into Cv where the color named Name was found (-1) if no such color was found

Definition at line 957 of file SUMA_Color.c.

References i, LocalHead, SUMA_Boolean, SUMA_ENTRY, SUMA_LH, SUMA_RETURN, and SUMA_S_Warn.

Referenced by SUMA_Add_Color(), SUMA_AFNI_Extract_Colors(), and SUMA_Get_AFNI_Default_Color_Maps().

00958 {
00959    static char FuncName[]={"SUMA_Find_Color"};
00960    int icol = -1, i;
00961    SUMA_Boolean LocalHead = NOPE;
00962    
00963    SUMA_ENTRY;
00964    
00965    if (!Cv) {
00966       SUMA_S_Warn("Nothing to do. NULL Cv");
00967       SUMA_RETURN(icol);
00968    }
00969    
00970    for (i=0; i < N_cols; ++i) {
00971       if (strcmp(Cv[i].Name, Name) == 0) {
00972          SUMA_LH("Found Color");
00973          icol = i;
00974          SUMA_RETURN(icol);
00975       }
00976    }
00977    
00978    SUMA_LH("Failed to find color");
00979    SUMA_RETURN(icol);   
00980 }

int SUMA_Find_ColorMap char *    Name,
SUMA_COLOR_MAP **    CMv,
int    N_maps,
int    sgn
 

Locate a colormap in the colormap vector.

Parameters:
Name  (char *) Name ('\0' terminated) name of colormap to be found
CMv  (SUMA_COLOR_MAP **) vector of pointers to colormaps to be searched
N_maps  (int) number of maps in CMv
sgn  (int) the sign of the map (-1, 0, +1) if sign = -2 then the sign is completely ignored and only Name is used for a match
Returns:
imap (int) the index into CMv where the colormap named Name was found (-1) if no such map was found

Definition at line 993 of file SUMA_Color.c.

References i, LocalHead, SUMA_Boolean, SUMA_ENTRY, SUMA_LH, SUMA_RETURN, and SUMA_S_Warn.

Referenced by SUMA_Add_ColorMap(), SUMA_CmapOfPlane(), SUMA_ColorOverlayPlane_Info(), SUMA_ScaleToMap_Interactive(), and SUMA_SetConvexityPlaneDefaults().

00994 {
00995    static char FuncName[]={"SUMA_Find_ColorMap"};
00996    int imap = -1, i;
00997    SUMA_Boolean LocalHead = NOPE;
00998    
00999    SUMA_ENTRY;
01000    
01001    if (!CMv) {
01002       SUMA_S_Warn("Nothing to do. NULL CMv");
01003       SUMA_RETURN(imap);
01004    }
01005    
01006    
01007    for (i=0; i < N_maps; ++i) {
01008       if (CMv[i]) {
01009          if (sgn != -2) {
01010             if (strcmp(CMv[i]->Name, Name) == 0 && CMv[i]->Sgn == sgn) {
01011                SUMA_LH("Found Map");
01012                imap = i;
01013                SUMA_RETURN(imap);
01014             }
01015          } else {
01016             /* don't care about sign */
01017             if (strcmp(CMv[i]->Name, Name) == 0 ) {
01018                SUMA_LH("Found Map");
01019                imap = i;
01020                SUMA_RETURN(imap);
01021             }
01022          }
01023       }
01024    }
01025    
01026    SUMA_LH("Failed to find map");
01027    SUMA_RETURN(imap);   
01028 }

void SUMA_Flip_Color_Map SUMA_COLOR_MAP   CM
 

flips a color map upside down

Parameters:
CM  (SUMA_COLOR_MAP *) to be flipped

Definition at line 4430 of file SUMA_Color.c.

References c, SUMA_COLOR_MAP::frac, i, LocalHead, SUMA_COLOR_MAP::M, SUMA_COLOR_MAP::N_Col, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURNe.

04431 {
04432    static char FuncName[] = {"SUMA_Flip_Color_Map"};
04433    int lim, i, j, c;
04434    float t;
04435    SUMA_Boolean LocalHead = NOPE;
04436    
04437    SUMA_ENTRY;
04438    
04439    if (!CM) SUMA_RETURNe;
04440    
04441    if (!CM->M) SUMA_RETURNe;
04442    
04443    lim = CM->N_Col/2;
04444    for (j=0; j < 3; ++j) {  /* loop accross R,G,B columns */
04445       for (i=0; i < lim; ++i) {
04446          t = CM->M[i][j];           /* store color at i to be flipped */
04447          c = CM->N_Col - i - 1;     /* index of color to replace one at i */
04448          CM->M[i][j] = CM->M[c][j]; /* replace color at i */
04449          CM->M[c][j] = t;           /* put old color of i ar c */
04450       } 
04451    }
04452    
04453    if (CM->frac) { /* got to flip fractions */
04454       for (i=0; i < lim; ++i) {
04455          t = CM->frac[i];           /* store fraction at i to be flipped */
04456          c = CM->N_Col - i - 1;     /* index of fraction to replace one at i */
04457          CM->frac[i] = CM->frac[c]; /* replace fraction at i */
04458          CM->frac[c] = t;           /* put old fraction of i at c */
04459       } 
04460    }
04461    
04462    SUMA_RETURNe;
04463 }

SUMA_Boolean SUMA_FlushPlaneNotInUse char *    PlaneName,
SUMA_SurfaceObject   SO,
SUMA_DO   dov,
int    N_dov
 

SUMA_FlushPlaneNotInUse (char *PlaneName, SUMA_SurfaceObject *SO, SUMA_DO *dov, int N_dov) Searches all DrawnROIs in dov. If no ROI related to SO has PlaneName for a color plane then that colorplane is flushed (ie no node colors are left in it, not deleted).

Definition at line 6283 of file SUMA_Color.c.

References COLP_N_NODEDEF, SUMA_DRAWN_ROI::ColPlaneName, i, LocalHead, SUMA_OVERLAYS::N_NodeDef, SUMA_SurfaceObject::N_Overlays, SUMA_SurfaceObject::Overlays, ROIdO_type, SUMA_Boolean, SUMA_ENTRY, SUMA_Fetch_OverlayPointer(), SUMA_isdROIrelated(), SUMA_LH, SUMA_RETURN, and SUMA_SLP_Warn.

Referenced by SUMA_cb_DrawROI_Delete().

06284 {
06285    static char FuncName[]={"SUMA_FlushPlaneNotInUse"};
06286    SUMA_DRAWN_ROI *D_ROI = NULL;
06287    int i, OverInd;
06288    SUMA_Boolean LocalHead = NOPE;
06289    
06290    SUMA_ENTRY;
06291    
06292    if (!PlaneName) SUMA_RETURN(YUP);
06293    
06294    /* search all dov for ROIs that use the same plane */
06295    for (i=0; i < N_dov; ++i) {
06296       switch (dov[i].ObjectType) { /* case Object Type */
06297          case ROIdO_type:
06298             D_ROI = (SUMA_DRAWN_ROI *)dov[i].OP;
06299             break;
06300          default:
06301             D_ROI = NULL;
06302             break;
06303       }
06304       if (D_ROI && SUMA_isdROIrelated (D_ROI, SO)) {
06305          if (strcmp(PlaneName, D_ROI->ColPlaneName) == 0) {
06306             /* found one, do nothing and return */
06307             SUMA_RETURN (YUP);
06308          }
06309       }
06310    }   
06311    
06312    /* looks like no other ROIs use that plane, flush it */
06313    if (!SUMA_Fetch_OverlayPointer (SO->Overlays, SO->N_Overlays, PlaneName, &OverInd)) {
06314       SUMA_SLP_Warn("No Overlay Plane Found!");
06315       SUMA_RETURN (YUP);
06316    }
06317    
06318    SUMA_LH("Flushing meadows");
06319    #if 0
06320       SO->Overlays[OverInd]->N_NodeDef = 0; /* Flushed */
06321    #else
06322       COLP_N_NODEDEF(SO->Overlays[OverInd]) = 0;
06323    #endif
06324    SUMA_RETURN (YUP);
06325 }

void SUMA_Free_ColorMap SUMA_COLOR_MAP   SM
 

function to free memory allocated for SUMA_COLOR_MAP

Definition at line 267 of file SUMA_Color.c.

References SUMA_COLOR_MAP::cname, SUMA_COLOR_MAP::frac, i, SUMA_COLOR_MAP::M, SUMA_COLOR_MAP::N_Col, SUMA_COLOR_MAP::Name, SUMA_COLOR_MAP::SO, SUMA_ENTRY, SUMA_free, SUMA_free2D(), SUMA_Free_Surface_Object(), and SUMA_RETURNe.

Referenced by SUMA_Add_ColorMap(), SUMA_DestroyAfniColors(), SUMA_Engine(), SUMA_Free_CommonFields(), SUMA_input(), SUMA_Read_Color_Map_1D(), SUMA_ScaleToMap(), SUMA_ScaleToMap_alaAFNI(), and SUMA_SphereQuality().

00268 {
00269    static char FuncName[]={"SUMA_Free_ColorMap"};
00270    int i = 0;
00271    
00272    SUMA_ENTRY;
00273 
00274    if (SM->Name) SUMA_free(SM->Name);
00275    if (SM->M) SUMA_free2D((char **)SM->M, SM->N_Col);
00276    if (SM->cname) {
00277       for (i=0; i<SM->N_Col; ++i) { if (SM->cname[i]) SUMA_free(SM->cname[i]); }
00278       SUMA_free(SM->cname);
00279    }
00280    if (SM->frac) SUMA_free(SM->frac);
00281    if (SM->SO) SUMA_Free_Surface_Object(SM->SO); 
00282    
00283    if (SM) SUMA_free(SM);
00284 
00285    SUMA_RETURNe;
00286 }

void SUMA_Free_ColorScaledVect SUMA_COLOR_SCALED_VECT   S
 

function to free structures of the type SUMA_COLOR_SCALED_VECT SUMA_Free_ColorScaledVect (S)

Parameters:
S  (SUMA_COLOR_SCALED_VECT * ) pointer to structure being deleted \ret void

Definition at line 2970 of file SUMA_Color.c.

References SUMA_COLOR_SCALED_VECT::BiasCoordVec, SUMA_COLOR_SCALED_VECT::cV, SUMA_COLOR_SCALED_VECT::isMasked, S, SUMA_ENTRY, SUMA_free, and SUMA_RETURNe.

Referenced by SUMA_input(), SUMA_ScaleToMap_Interactive(), and SUMA_SphereQuality().

02971 {
02972    static char FuncName[]={"SUMA_Free_ColorScaledVect"};
02973    
02974    SUMA_ENTRY;
02975 
02976    if (S->cV) SUMA_free(S->cV);
02977    if (S->isMasked) SUMA_free(S->isMasked);
02978    if (S->BiasCoordVec) SUMA_free(S->BiasCoordVec);
02979    if (S) SUMA_free(S);
02980    SUMA_RETURNe;
02981 }

void SUMA_FreeOverlayListDatum void *    OLDv
 

Frees SUMA_OVERLAY_LIST_DATUM * used in the linked list.

Definition at line 5469 of file SUMA_Color.c.

References LocalHead, SUMA_Boolean, SUMA_ENTRY, SUMA_free, and SUMA_RETURNe.

Referenced by SUMA_OverlaysToOrderedList().

05470 {
05471    static char FuncName[]={"SUMA_FreeOverlayListDatum"};
05472    SUMA_Boolean LocalHead = NOPE; 
05473    
05474    SUMA_ENTRY; 
05475 
05476    if (OLDv) SUMA_free(OLDv); 
05477    
05478    SUMA_RETURNe;
05479 }

SUMA_Boolean SUMA_FreeOverlayPointer SUMA_OVERLAYS   Sover
 

Function to free an overlay structure ans = SUMA_FreeOverlayPointer (Sover);

Parameters:
Sover  (SUMA_OVERLAYS * ) \ret ans (SUMA_Boolean) (YUP/NOPE)
-WARNING, If YOU CREATED AN INODE FOR THIS POINTER, YOU NEED TO RELASE IT BEFORE YOU FREE Sover Perhaps you should use SUMA_FreeOverlay (SUMA_OVERLAYS * Sover, SUMA_INODE *Sover_Inode);

If you free one overlay structure at a time, take care to make sure the plane orders still make sense

Definition at line 4728 of file SUMA_Color.c.

References SUMA_OVERLAYS::cmapname, SUMA_OVERLAYS::ColVec, SUMA_OVERLAYS::dset_link, SUMA_OVERLAYS::Label, SUMA_OVERLAYS::LocalOpacity, SUMA_OVERLAYS::N_links, SUMA_OVERLAYS::Name, SUMA_OVERLAYS::NodeDef, SUMA_OVERLAYS::OptScl, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_RETURN, and SUMA_UnlinkFromPointer().

Referenced by SUMA_Free_Surface_Object(), SUMA_iRGB_to_OverlayPointer(), SUMA_LoadDsetFile(), SUMA_PrepAddmappableSO(), and SUMA_ReleaseOverlay().

04729 {
04730    static char FuncName[]={"SUMA_FreeOverlayPointer"};
04731    
04732    SUMA_ENTRY;
04733 
04734    if (Sover == NULL) {
04735       fprintf (SUMA_STDERR,"Error %s: Sover is NULL, nothing to do. Returning OK flag.\n", FuncName);
04736       SUMA_RETURN (YUP);
04737    }
04738    /* is this pointer used by others ? */
04739    if (Sover->N_links) {
04740       Sover = (SUMA_OVERLAYS*)SUMA_UnlinkFromPointer((void *)Sover);
04741       SUMA_RETURN (YUP);
04742    }
04743    
04744    /* No more links, go for it */
04745    if (Sover->dset_link) Sover->dset_link = (SUMA_DSET *)SUMA_UnlinkFromPointer((void *)Sover->dset_link);
04746    if (Sover->NodeDef) SUMA_free(Sover->NodeDef);
04747    /* if (Sover->ColMat) SUMA_free2D ((char **)Sover->ColMat, Sover->N_Alloc); */
04748    if (Sover->ColVec)  SUMA_free(Sover->ColVec);
04749    if (Sover->LocalOpacity) SUMA_free(Sover->LocalOpacity);
04750    if (Sover->Label) SUMA_free(Sover->Label);
04751    if (Sover->Name) SUMA_free(Sover->Name);
04752    if (Sover->cmapname) SUMA_free(Sover->cmapname);
04753    if (Sover->OptScl) SUMA_free(Sover->OptScl);
04754    SUMA_free(Sover); Sover = NULL;
04755    
04756    SUMA_RETURN (YUP);
04757 }

SUMA_AFNI_COLORS* SUMA_Get_AFNI_Default_Color_Maps  
 

Builds the SUMA_AFNI_COLORS structure which contains the Named colors and colormaps defined in AFNI The colors and colormaps loaded are the ones that are found in AFNI when AFNI is first started.

  • Continuous colormaps are NOT loaded.
    • Colors and colormaps defined in the .afnirc are loaded
See also:
SUMA_DestroyAfniColors (for deleting returned structure)

Definition at line 299 of file SUMA_Color.c.

References SUMA_RGB_NAME::b, SUMA_AFNI_COLORS::CMv, SUMA_COLOR_MAP::cname, SUMA_AFNI_COLORS::Cv, SUMA_COLOR_MAP::frac, SUMA_RGB_NAME::g, getenv(), i, INIT_ncolovr, INIT_ovin_pos, INIT_ovin_sgn, INIT_pval_pos, INIT_pval_sgn, LocalHead, SUMA_COLOR_MAP::M, SUMA_COLOR_MAP::N_Col, SUMA_AFNI_COLORS::N_cols, SUMA_AFNI_COLORS::N_maps, SUMA_COLOR_MAP::Name, NPANE_MAX, NPANE_MIN, SUMA_RGB_NAME::r, SUMA_COLOR_MAP::Sgn, SUMA_COLOR_MAP::SO, stbuf, SUMA_Add_Color(), SUMA_Add_ColorMap(), SUMA_AFNI_Extract_Colors(), SUMA_allocate2D(), SUMA_append_string(), SUMA_Boolean, SUMA_calloc, SUMA_copy_string(), SUMA_ENTRY, SUMA_Find_Color(), SUMA_free, SUMA_Interpret_AFNIColor(), SUMA_LH, SUMA_malloc, SUMA_RETURN, SUMA_Show_ColorMapVec(), SUMA_Show_ColorVec(), and SUMA_SL_Crit.

Referenced by SUMA_Build_Color_maps().

00300 {
00301    static char FuncName[]={"SUMA_Get_AFNI_Default_Color_Maps"};
00302    float rgb[3];
00303    SUMA_RGB_NAME *Cv = NULL;
00304    SUMA_COLOR_MAP **CMv=NULL;
00305    SUMA_COLOR_MAP *CMp=NULL, *CMn=NULL;
00306    SUMA_AFNI_COLORS *SAC=NULL;
00307    int i, j, icol;
00308    int N_maps, N_cols;
00309    int       ival , ii,jj ;
00310    float     fval ;
00311    float     pthr[NPANE_MAX+1] ;
00312    int       pov[NPANE_MAX+1] ;
00313    char *homeenv=NULL, *sumarc=NULL;
00314    struct stat stbuf;
00315    SUMA_Boolean LocalHead_Detail = NOPE;
00316    SUMA_Boolean LocalHead = NOPE;
00317    
00318    SUMA_ENTRY;
00319    
00320    
00321    /* initilialize*/
00322    N_maps = -1;
00323    N_cols = -1;
00324 
00325    /* add the none color first */
00326    Cv = SUMA_Add_Color ("none", 
00327                         -1.0, -1.0, -1.0, 1.0, 
00328                         Cv, &N_cols);
00329                         
00330    /* get the rgb, floats of each color defined DEFAULT_NCOLOVR */
00331    for (i=0; i<DEFAULT_NCOLOVR; ++i) {
00332       if (!SUMA_Interpret_AFNIColor (INIT_def_colovr[i], rgb)) {
00333          fprintf(SUMA_STDERR,"Error %s: Failed to interpret color %s : %s\n", FuncName, INIT_def_labovr[i], INIT_def_colovr[i]);
00334       } else {
00335          if (LocalHead_Detail) fprintf(SUMA_STDERR,"%s: Adding color...", FuncName); 
00336          Cv = SUMA_Add_Color (INIT_def_labovr[i], 
00337                            rgb[0], rgb[1], rgb[2], 1.0, 
00338                            Cv, &N_cols);
00339      } 
00340    }
00341    
00342    /* Now create the afni color maps with more than 10 panes (excerpts from afni.c)*/
00343    
00344    /* start with positive panes */
00345    for( ii=NPANE_INIT+1 ; ii <= NPANE_MAX ; ii++ ){
00346       fval     = 1.0 / ii ;
00347       pthr[0]  = 1.0 ;
00348       pthr[ii] = 0.0 ;
00349       for( jj=1 ; jj < ii ; jj++ ) pthr[jj] = fval * (ii-jj) ;
00350       for( jj=0 ; jj < ii ; jj++ ) pov[jj]  = (jj % INIT_ncolovr) + 1 ;
00351 
00352       for( jj=0 ; jj <= ii ; jj++ ) INIT_pval_pos[ii][jj] = pthr[jj] ;
00353       for( jj=0 ; jj <  ii ; jj++ ) INIT_ovin_pos[ii][jj] = pov[jj] ;
00354    }
00355 
00356    /** initialize signed pbar panes **/
00357    for( ii=NPANE_INIT+1 ; ii <= NPANE_MAX ; ii++ ){
00358       fval     =  1.0 / ii ;
00359       pthr[0]  =  1.0 ;
00360       pthr[ii] = -1.0 ;
00361       for( jj=1 ; jj < ii ; jj++ ) pthr[jj] = fval * (ii-2*jj) ;
00362       for( jj=0 ; jj < ii ; jj++ ) pov[jj]  = (jj % INIT_ncolovr) + 1 ;
00363 
00364       for( jj=0 ; jj <= ii ; jj++ ) INIT_pval_sgn[ii][jj] = pthr[jj] ;
00365       for( jj=0 ; jj <  ii ; jj++ ) INIT_ovin_sgn[ii][jj] = pov[jj] ;
00366    }
00367    
00368 #if defined(RGBCYC_COUNT) && RGBCYC_COUNT <= NPANE_MAX
00369    ii = RGBCYC_COUNT ;
00370    for( jj=0 ; jj < ii ; jj++ ) INIT_ovin_pos[ii][jj] = RGBCYC_FIRST+jj+1 ;
00371    for( jj=0 ; jj < ii ; jj++ ) INIT_ovin_sgn[ii][jj] = RGBCYC_FIRST+jj+1 ;
00372 #endif
00373 
00374    
00375    /* now create AFNI's colormaps */
00376    for (i = NPANE_MIN; i<= NPANE_MAX; ++i) {
00377       CMp = (SUMA_COLOR_MAP *)SUMA_malloc(sizeof(SUMA_COLOR_MAP));
00378       CMn = (SUMA_COLOR_MAP *)SUMA_malloc(sizeof(SUMA_COLOR_MAP));
00379       if (CMp == NULL || CMn == NULL) {
00380          SUMA_SL_Crit ("Failed to allocate for CMp &/| CMn.");
00381          SUMA_RETURN(NULL);
00382       }
00383 
00384       CMp->SO = NULL; 
00385       CMn->SO = NULL; 
00386       CMp->cname = NULL;
00387       CMn->cname = NULL;
00388       CMp->N_Col = i; 
00389       CMn->N_Col = i;
00390       CMp->Sgn = 1;
00391       CMn->Sgn = -1;
00392       
00393       CMp->Name = (char *)SUMA_calloc(25, sizeof(char));
00394       CMn->Name = (char *)SUMA_calloc(25, sizeof(char));
00395       CMp->frac = (float *)SUMA_calloc(i, sizeof(float));
00396       CMn->frac = (float *)SUMA_calloc(i, sizeof(float));
00397       CMp->M = (float**)SUMA_allocate2D (CMp->N_Col, 3, sizeof(float));
00398       CMn->M = (float**)SUMA_allocate2D (CMn->N_Col, 3, sizeof(float));
00399       if (  CMp->frac == NULL || CMn->frac == NULL 
00400          || CMp->M == NULL || CMn->M == NULL 
00401          || CMp->Name == NULL || CMn->Name == NULL ) {
00402          SUMA_SL_Crit ("Failed to allocate for fields of CMp &/| CMn.");
00403          SUMA_RETURN (NULL);
00404       }
00405       
00406       sprintf(CMp->Name,   "afni_p%d",i); 
00407       sprintf(CMn->Name, "afni_n%d",i);
00408       
00409       if (LocalHead_Detail) fprintf (SUMA_STDERR,"%s: Building colormap POS #%d (%s)\n", FuncName, i, CMp->Name);
00410       
00411       for ( j = 0; j < i; ++j) {
00412          if (!INIT_ovin_pos[i][j]) {
00413             if (LocalHead_Detail) {
00414                fprintf (SUMA_STDERR,"\t[i%d] NoColor\t%f\n", 
00415                               INIT_ovin_pos[i][j], 
00416                               INIT_pval_pos[i][j]);   
00417             }
00418             CMp->M[i - j - 1][0] = CMp->M[i - j - 1][1] = CMp->M[i - j - 1][2] = -1.0; 
00419          } else {
00420             if (LocalHead_Detail) {
00421                fprintf (SUMA_STDERR,"\t[i%d] %s\t%f\n", 
00422                               INIT_ovin_pos[i][j], 
00423                               INIT_def_labovr[INIT_ovin_pos[i][j]-1], INIT_pval_pos[i][j]);
00424             }
00425             /* find out which color this is */
00426             icol = SUMA_Find_Color (INIT_def_labovr[INIT_ovin_pos[i][j]-1], Cv, N_cols);
00427             if (icol < 0) {
00428                fprintf (SUMA_STDERR,"Error%s: Failed to find color %s\nUsing no-color in its place\n", 
00429                                        FuncName, INIT_def_labovr[INIT_ovin_pos[i][j]-1]);
00430                CMp->M[i - j - 1][0] = CMp->M[i - j - 1][1] = CMp->M[i - j - 1][2] = -1.0; 
00431             } else {
00432                CMp->M[i - j - 1][0] = Cv[icol].r;
00433                CMp->M[i - j - 1][1] = Cv[icol].g;
00434                CMp->M[i - j - 1][2] = Cv[icol].b;
00435             }
00436          }
00437          CMp->frac[i - j - 1] = INIT_pval_pos[i][j];
00438       }
00439       
00440       /* add the positive map to the list */
00441       CMv = SUMA_Add_ColorMap (CMp, CMv, &N_maps);
00442       if (!CMv) {
00443          SUMA_SL_Crit("Failed in SUMA_Add_ColorMap");
00444          SUMA_RETURN(NULL);
00445       }
00446       
00447       if (LocalHead_Detail) fprintf (SUMA_STDERR,"%s: Building colormap SGN #%d (%s)\n", FuncName, i, CMn->Name);
00448       
00449       for ( j = 0; j < i; ++j) {
00450          if (!INIT_ovin_sgn[i][j]) {
00451             if (LocalHead_Detail) {
00452                fprintf (SUMA_STDERR,"\t[i%d] NoColor\t%f\n", 
00453                               INIT_ovin_sgn[i][j], 
00454                               INIT_pval_sgn[i][j]);
00455             }
00456             CMn->M[i - j - 1][0] = CMn->M[i - j - 1][1] = CMn->M[i - j - 1][2] = -1.0;
00457          } else {
00458             if (LocalHead_Detail) {
00459                fprintf (SUMA_STDERR,"\t[i%d] %s\t%f\n", 
00460                               INIT_ovin_sgn[i][j], 
00461                               INIT_def_labovr[INIT_ovin_sgn[i][j]-1], INIT_pval_sgn[i][j]);
00462             }
00463             icol = SUMA_Find_Color (INIT_def_labovr[INIT_ovin_sgn[i][j]-1], Cv, N_cols);
00464             if (icol < 0) {
00465                fprintf (SUMA_STDERR,"Error%s: Failed to find color %s\nUsing no-color in its place", 
00466                                     FuncName, INIT_def_labovr[INIT_ovin_sgn[i][j]-1]);
00467                CMn->M[i - j - 1][0] = CMn->M[i - j - 1][1] = CMn->M[i - j - 1][2] = -1.0;
00468             } else {
00469                CMn->M[i - j - 1][0] = Cv[icol].r;
00470                CMn->M[i - j - 1][1] = Cv[icol].g;
00471                CMn->M[i - j - 1][2] = Cv[icol].b;
00472             }
00473          }
00474          CMn->frac[i - j - 1] = INIT_pval_sgn[i][j];
00475       }
00476       
00477       /* add the negative map to the list */
00478       CMv = SUMA_Add_ColorMap (CMn, CMv, &N_maps);
00479       if (!CMv) {
00480          SUMA_SL_Crit("Failed in SUMA_Add_ColorMap");
00481          SUMA_RETURN(NULL);
00482       }
00483    }
00484    
00485    
00486    /* perhaps someday include the continuous color maps from AFNI too. 
00487       (see pbar.c file, search for colorscale) */
00488    
00489       
00490    SAC = (SUMA_AFNI_COLORS *) SUMA_malloc(sizeof(SUMA_AFNI_COLORS));
00491    SAC->CMv = CMv;
00492    SAC->N_maps = N_maps;
00493    SAC->Cv = Cv;
00494    SAC->N_cols = N_cols;
00495 
00496    /* load whatever's lurking in the .afnirc files */
00497    /* passing NULL for dc (the last parameter) because I
00498    am not using the continuous color maps yet */
00499    SUMA_LH("Calling Process setup");
00500    homeenv = getenv("HOME");   
00501    
00502    if (!homeenv) sumarc = SUMA_copy_string(".afnirc");
00503    else sumarc = SUMA_append_string (homeenv, "/.afnirc");
00504    if (stat(sumarc, &stbuf) != -1) {
00505       if (LocalHead) fprintf (SUMA_STDERR,"%s: Loading %s ...\n", FuncName, sumarc);
00506       if (SUMA_AFNI_Extract_Colors ( sumarc, SAC ) < 0) {
00507          fprintf(SUMA_STDERR,"Error %s: Failed scanning .afnirc for colors and colormaps.\nProceeding ...\n", FuncName);
00508       } 
00509    } else {
00510       if (LocalHead) fprintf (SUMA_STDERR,"%s: No rc files found.\n", FuncName);
00511    }
00512    if (sumarc) SUMA_free(sumarc);
00513    
00514    /* Show me the results: */
00515    if (LocalHead_Detail) {
00516       SUMA_Show_ColorVec (SAC->Cv, SAC->N_cols, NULL);
00517    }
00518    
00519    if (LocalHead_Detail) {
00520       SUMA_Show_ColorMapVec (SAC->CMv, SAC->N_maps, NULL, 1);
00521    }   
00522    
00523    SUMA_LH("Returning");
00524    
00525    SUMA_RETURN(SAC);
00526 }

int SUMA_GetLargestBackroundOrder DList   listop
 

returns the largest background order in the list of verlay planes

Definition at line 5622 of file SUMA_Color.c.

References DListElmt_::data, dlist_head, dlist_is_tail, i, SUMA_OVERLAYS::isBackGrnd, LocalHead, DListElmt_::next, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_OVERLAYS::PlaneOrder, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

05623 {
05624    static char FuncName[]={"SUMA_GetLargestBackroundOrder"};
05625    int Order, i;
05626    DListElmt *Elmop=NULL;
05627    SUMA_OVERLAY_LIST_DATUM *OvD = NULL;
05628    SUMA_Boolean LocalHead = NOPE;
05629       
05630    SUMA_ENTRY;
05631 
05632    Order = 0;
05633    Elmop = NULL;
05634    do {
05635       if (!Elmop) Elmop = dlist_head(listop);
05636       else Elmop = Elmop->next;
05637       OvD = (SUMA_OVERLAY_LIST_DATUM *)Elmop->data;
05638       if (OvD->Overlay->isBackGrnd) {
05639          if (OvD->Overlay->PlaneOrder > Order) Order = OvD->Overlay->PlaneOrder;
05640       }
05641       ++i;
05642    } while (!dlist_is_tail(Elmop));
05643    
05644    if (LocalHead) {
05645       fprintf (SUMA_STDERR,"%s: Highest background order found is %d\n", FuncName, Order);
05646    }
05647    
05648    SUMA_RETURN(Order);
05649 }

int SUMA_GetNodeOverInd SUMA_OVERLAYS   Sover,
int    node
 

j = SUMA_GetNodeOverInd(Sover, node); returns the index, into Sover->NodeDef such that Sover->NodeDef[j] = node;

See also:
SUMA_GetNodeRow_FromNodeIndex

Definition at line 7512 of file SUMA_Color.c.

References SUMA_DSET::dnel, SUMA_OVERLAYS::dset_link, i, LocalHead, SUMA_OVERLAYS::N_NodeDef, SUMA_OVERLAYS::NodeDef, SUMA_Boolean, SUMA_ENTRY, SUMA_LH, SUMA_RETURN, and NI_element::vec_filled.

Referenced by SUMA_UpdateNodeLblField().

07513 {
07514    static char FuncName[]={"SUMA_GetNodeOverInd"};
07515    int Found, i;
07516    SUMA_Boolean LocalHead = NOPE;
07517 
07518    SUMA_ENTRY;
07519 
07520    /* Now look for the node's location in the color overlay plane.
07521    Nodes that are not colored will be absent ... */
07522    Found = -1;
07523    if (Sover->dset_link->dnel->vec_filled > node) { /* try the straight shot */
07524       if (Sover->NodeDef[node] == node) {
07525          SUMA_LH("Good, found it easily");
07526          /* make sure node is not outside number of defined nodes */
07527          if (node >= Sover->N_NodeDef) {
07528             /* this one's masked but it was left over from the previous pass 
07529             Must go search below to make sure whether it is truly masked or not*/
07530             SUMA_LH("Can't tell for sure");
07531          } else {
07532             SUMA_RETURN(node);
07533          }
07534       }
07535    }
07536    if (Found < 0) {
07537       SUMA_LH("The hard way");
07538       i=0; 
07539       while (Found <0 && i<Sover->N_NodeDef) {
07540          if (Sover->NodeDef[i] == node) Found = i;
07541          ++i;
07542       }      
07543    }   
07544 
07545    SUMA_RETURN(Found);
07546 }

int SUMA_GetSmallestForegroundOrder DList   listop
 

returns the lowest foreground plane order in the list of overlay planes

Definition at line 5654 of file SUMA_Color.c.

References DListElmt_::data, dlist_head, dlist_is_tail, i, SUMA_OVERLAYS::isBackGrnd, LocalHead, DListElmt_::next, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_OVERLAYS::PlaneOrder, DList_::size, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

05655 {
05656    static char FuncName[]={"SUMA_GetSmallestForegroundOrder"};
05657    int Order, i;
05658    DListElmt *Elmop=NULL;
05659    SUMA_OVERLAY_LIST_DATUM *OvD = NULL, *oOvD = NULL;
05660    SUMA_Boolean LocalHead = NOPE;
05661       
05662    SUMA_ENTRY;
05663 
05664    Order = listop->size -1 ;
05665    Elmop = NULL;
05666    do {
05667       if (!Elmop) Elmop = dlist_head(listop);
05668       else Elmop = Elmop->next;
05669       OvD = (SUMA_OVERLAY_LIST_DATUM *)Elmop->data;
05670       if (!OvD->Overlay->isBackGrnd) {
05671          if (OvD->Overlay->PlaneOrder < Order) Order = OvD->Overlay->PlaneOrder;
05672       }
05673       ++i;
05674    } while (!dlist_is_tail(Elmop));
05675    
05676    if (LocalHead) {
05677       fprintf (SUMA_STDERR,"%s: Lowest foreground order found is %d\n", FuncName, Order);
05678    }
05679    
05680    SUMA_RETURN(Order);
05681 }

SUMA_COLOR_MAP* SUMA_GetStandardMap SUMA_STANDARD_CMAP    mapcode
 

Returns one of a bunch of standard SUMA colormaps CM = SUMA_GetStandardMap (mapname);

Parameters:
mapname  (SUMA_STANDARD_CMAP) type of color map, choose from SUMA_CMAP_RGYBR20 SUMA_CMAP_BGYR19 SUMA_CMAP_GRAY20 SUMA_CMAP_GRAY02 SUMA_CMAP_nGRAY20 SUMA_CMAP_BW20 SUMA_CMAP_MATLAB_DEF_BYR64
Returns:
CM (SUMA_COLOR_MAP*) color map structure (NULL in case of error)

Definition at line 3193 of file SUMA_Color.c.

References nc, SUMA_allocate2D(), SUMA_calloc, SUMA_CMAP_BGYR19, SUMA_CMAP_BGYR64, SUMA_CMAP_BW20, SUMA_CMAP_flpGRAY02, SUMA_CMAP_GRAY02, SUMA_CMAP_GRAY20, SUMA_CMAP_MATLAB_DEF_BYR64, SUMA_CMAP_nGRAY20, SUMA_CMAP_RGYBR20, SUMA_CMAP_ROI128, SUMA_CMAP_ROI256, SUMA_CMAP_ROI64, SUMA_ENTRY, SUMA_free, SUMA_free2D(), SUMA_MakeColorMap(), SUMA_MakeColorMap_v2(), SUMA_RETURN, SUMA_STANDARD_CMAP, and SUMA_StandardMapName().

Referenced by main(), SUMA_Build_Color_maps(), SUMA_Engine(), SUMA_input(), SUMA_NodeVal2irgba_nel(), SUMA_Paint_SO_ROIplanes(), and SUMA_SphereQuality().

03194 {     static char FuncName[]={"SUMA_GetStandardMap"};
03195       float **Fiducials;
03196       int k, nc;
03197       int *Nind;
03198       int Ncols, NFid;
03199       SUMA_COLOR_MAP * CM;
03200       
03201    SUMA_ENTRY;
03202 
03203       switch (mapcode) {
03204          case SUMA_CMAP_RGYBR20:
03205             {               
03206                Fiducials = (float **)SUMA_allocate2D(5, 3, sizeof(float));
03207                if (!Fiducials) {
03208                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials.\n", FuncName);
03209                   SUMA_RETURN (NULL);
03210                }
03211                /* create the fiducial colors */
03212                k = 0;
03213                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; ++k;/* Red */
03214                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.0; ++k;/* Green */
03215                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 1.0; ++k;/* Blue */
03216                Fiducials[k][0] = 1.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.0; ++k;/* Yellow */
03217                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; ++k;/* Red */
03218 
03219                /* generate 20 colors colormap */
03220                CM = SUMA_MakeColorMap (Fiducials, k, 20, YUP, SUMA_StandardMapName(mapcode,&nc));
03221                /* free Fiducials */
03222                SUMA_free2D((char **)Fiducials, k);
03223                
03224                if (!CM) {
03225                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03226                   SUMA_RETURN (NULL);   
03227                }
03228                break;
03229             }
03230          case SUMA_CMAP_BGYR19:
03231             {
03232                Fiducials = (float **)SUMA_allocate2D(4, 3, sizeof(float));
03233                if (!Fiducials) {
03234                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials.\n", FuncName);
03235                   SUMA_RETURN (NULL);
03236                }
03237                /* create the fiducial colors */
03238                k = 0;
03239                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 1.0; ++k;/* Blue */
03240                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.0; ++k;/* Green */
03241                Fiducials[k][0] = 1.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.0; ++k;/* Yellow */
03242                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; ++k;/* Red */
03243 
03244                /* generate 20 colors colormap */
03245                CM = SUMA_MakeColorMap (Fiducials, k, 19, NOPE, SUMA_StandardMapName(mapcode,&nc));
03246                /* free Fiducials */
03247                SUMA_free2D((char **)Fiducials, k);
03248                
03249                if (!CM) {
03250                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03251                   SUMA_RETURN (NULL);   
03252                }
03253                break;
03254             }
03255             
03256          case SUMA_CMAP_GRAY02:
03257             {
03258                Fiducials = (float **)SUMA_allocate2D(2, 3, sizeof(float));
03259                if (!Fiducials) {
03260                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials.\n", FuncName);
03261                   SUMA_RETURN (NULL);
03262                }
03263                /* create the fiducial colors */
03264                k = 0;
03265                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.4; ++k;/* 0.4 gray */
03266                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.7; ++k;/* 0.8 gray */
03267 
03268                /* generate 2 colors colormap */
03269                CM = SUMA_MakeColorMap (Fiducials, k, 2, NOPE, SUMA_StandardMapName(mapcode,&nc));
03270                /* free Fiducials */
03271                SUMA_free2D((char **)Fiducials, k);
03272                
03273                if (!CM) {
03274                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03275                   SUMA_RETURN (NULL);   
03276                }
03277                break;
03278             }   
03279          
03280          case SUMA_CMAP_flpGRAY02:
03281             {
03282                Fiducials = (float **)SUMA_allocate2D(2, 3, sizeof(float));
03283                if (!Fiducials) {
03284                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials.\n", FuncName);
03285                   SUMA_RETURN (NULL);
03286                }
03287                /* create the fiducial colors */
03288                k = 0;
03289                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.7; ++k;
03290                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.4; ++k;
03291 
03292                /* generate 2 colors colormap */
03293                CM = SUMA_MakeColorMap (Fiducials, k, 2, NOPE, SUMA_StandardMapName(mapcode,&nc));
03294                /* free Fiducials */
03295                SUMA_free2D((char **)Fiducials, k);
03296                
03297                if (!CM) {
03298                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03299                   SUMA_RETURN (NULL);   
03300                }
03301                break;
03302             }            
03303          case SUMA_CMAP_GRAY20:
03304             {
03305                Fiducials = (float **)SUMA_allocate2D(2, 3, sizeof(float));
03306                if (!Fiducials) {
03307                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials.\n", FuncName);
03308                   SUMA_RETURN (NULL);
03309                }
03310                /* create the fiducial colors */
03311                k = 0;
03312                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.3; ++k;/* 0.3 gray */
03313                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.8; ++k;/* 0.8 gray */
03314 
03315                /* generate 20 colors colormap */
03316                CM = SUMA_MakeColorMap (Fiducials, k, 20, NOPE, SUMA_StandardMapName(mapcode,&nc));
03317                /* free Fiducials */
03318                SUMA_free2D((char **)Fiducials, k);
03319                
03320                if (!CM) {
03321                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03322                   SUMA_RETURN (NULL);   
03323                }
03324                break;
03325             }
03326          
03327          case SUMA_CMAP_nGRAY20:
03328             {
03329                Fiducials = (float **)SUMA_allocate2D(2, 3, sizeof(float));
03330                if (!Fiducials) {
03331                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials.\n", FuncName);
03332                   SUMA_RETURN (NULL);
03333                }
03334                /* create the fiducial colors */
03335                k = 0;
03336                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.3; ++k;/* 0.3 gray */
03337                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.8; ++k;/* 0.8 gray */
03338 
03339                /* generate 20 colors colormap */
03340                CM = SUMA_MakeColorMap (Fiducials, k, 20, NOPE, SUMA_StandardMapName(mapcode,&nc));
03341                /* free Fiducials */
03342                SUMA_free2D((char **)Fiducials, k);
03343                
03344                if (!CM) {
03345                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03346                   SUMA_RETURN (NULL);   
03347                }
03348                break;
03349             }
03350             
03351          case SUMA_CMAP_BW20:
03352             {
03353                Fiducials = (float **)SUMA_allocate2D(2, 3, sizeof(float));
03354                if (!Fiducials) {
03355                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials.\n", FuncName);
03356                   SUMA_RETURN (NULL);
03357                }
03358                /* create the fiducial colors */
03359                k = 0;
03360                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 0.0; ++k;/* black  */
03361                Fiducials[k][0] = Fiducials[k][1] = Fiducials[k][2] = 1.0; ++k;/* white */
03362 
03363                /* generate 20 colors colormap */
03364                CM = SUMA_MakeColorMap (Fiducials, k, 20, NOPE, SUMA_StandardMapName(mapcode,&nc));
03365                /* free Fiducials */
03366                SUMA_free2D((char **)Fiducials, k);
03367                
03368                if (!CM) {
03369                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03370                   SUMA_RETURN (NULL);   
03371                }
03372                break;
03373             }
03374             case SUMA_CMAP_MATLAB_DEF_BYR64:
03375             {
03376                /* default matlab color map */
03377                Ncols = 64;
03378                NFid = 10;
03379                
03380                Fiducials = (float **)SUMA_allocate2D(NFid, 3, sizeof(float));
03381                Nind = (int *) SUMA_calloc (NFid, sizeof (int));
03382                
03383                if (!Fiducials || !Nind) {
03384                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials or Nind.\n", FuncName);
03385                   SUMA_RETURN (NULL);
03386                }
03387                
03388                /* create the fiducial colors */
03389                k = 0;
03390                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.5625; Nind[k] = 0; ++k; 
03391                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 1.0; Nind[k] = 7; ++k;
03392                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.5; Fiducials[k][2] = 1.0; Nind[k] = 15; ++k;
03393                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 1.0; Nind[k] = 23; ++k;
03394                Fiducials[k][0] = 0.5; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.5625; Nind[k] = 31; ++k;
03395                Fiducials[k][0] = 0.5625; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.5; Nind[k] = 32; ++k;
03396                Fiducials[k][0] = 1.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.0; Nind[k] = 40; ++k;
03397                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.5; Fiducials[k][2] = 0.0; Nind[k] = 48; ++k;
03398                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; Nind[k] = 56; ++k;
03399                Fiducials[k][0] = 0.5625; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; Nind[k] = 63; ++k;
03400                
03401                /* generate 20 colors colormap */
03402                CM = SUMA_MakeColorMap_v2 (Fiducials, k, Nind, NOPE, SUMA_StandardMapName(mapcode,&nc));
03403                
03404                /* free Fiducials & Nind*/
03405                SUMA_free2D((char **)Fiducials, k);
03406                SUMA_free(Nind);
03407                
03408                if (!CM) {
03409                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03410                   SUMA_RETURN (NULL);   
03411                }
03412                break;
03413             
03414             }
03415          
03416             case SUMA_CMAP_BGYR64:
03417             {
03418                /* default matlab color map */
03419                Ncols = 64;
03420                NFid = 10;
03421                
03422                Fiducials = (float **)SUMA_allocate2D(NFid, 3, sizeof(float));
03423                Nind = (int *) SUMA_calloc (NFid, sizeof (int));
03424                
03425                if (!Fiducials || !Nind) {
03426                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials or Nind.\n", FuncName);
03427                   SUMA_RETURN (NULL);
03428                }
03429                
03430                /* create the fiducial colors */
03431                k = 0;
03432                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.5625; Nind[k] = 0; ++k; 
03433                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 1.0; Nind[k] = 7; ++k;
03434                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.5; Fiducials[k][2] = 1.0; Nind[k] = 15; ++k;
03435                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 1.0; Nind[k] = 18; ++k;
03436                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0.5; Fiducials[k][2] = 0.0; Nind[k] = 24; ++k;
03437                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.0; Nind[k] = 32; ++k;
03438                Fiducials[k][0] = 1.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0.0; Nind[k] = 43; ++k;
03439                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.5; Fiducials[k][2] = 0.0; Nind[k] = 48; ++k;
03440                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; Nind[k] = 56; ++k;
03441                Fiducials[k][0] = 0.5625; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; Nind[k] = 63; ++k;
03442                
03443                /* generate 64 colors colormap */
03444                CM = SUMA_MakeColorMap_v2 (Fiducials, k, Nind, NOPE, SUMA_StandardMapName(mapcode,&nc));
03445                
03446                /* free Fiducials & Nind*/
03447                SUMA_free2D((char **)Fiducials, k);
03448                SUMA_free(Nind);
03449                
03450                if (!CM) {
03451                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03452                   SUMA_RETURN (NULL);   
03453                }
03454                break;
03455             
03456             }
03457          case SUMA_CMAP_ROI256:
03458             {
03459                /* a large colormap for lots of ROI drawing */
03460                Ncols = 256;
03461                NFid = 6;
03462                
03463                Fiducials = (float **)SUMA_allocate2D(NFid, 3, sizeof(float));
03464                Nind = (int *) SUMA_calloc (NFid, sizeof (int));
03465                
03466                if (!Fiducials || !Nind) {
03467                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials or Nind.\n", FuncName);
03468                   SUMA_RETURN (NULL);
03469                }
03470                
03471                /* create the fiducial colors */
03472                k = 0;
03473                Fiducials[k][0] = 1.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0; Nind[k] = 0; ++k; 
03474                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0; Nind[k] = 50; ++k;
03475                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0; Fiducials[k][2] = 1.0; Nind[k] = 100; ++k;
03476                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; Nind[k] = 150; ++k;
03477                Fiducials[k][0] = 0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 1; Nind[k] = 200; ++k;
03478                Fiducials[k][0] = 1; Fiducials[k][1] = 0; Fiducials[k][2] = 1; Nind[k] = 255; ++k;
03479                
03480                
03481                /* generate colormap */
03482                CM = SUMA_MakeColorMap_v2 (Fiducials, k, Nind, NOPE, SUMA_StandardMapName(mapcode,&nc));
03483                
03484                /* free Fiducials & Nind*/
03485                SUMA_free2D((char **)Fiducials, k);
03486                SUMA_free(Nind);
03487                
03488                if (!CM) {
03489                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03490                   SUMA_RETURN (NULL);   
03491                }
03492                break;
03493             
03494             }
03495          
03496 
03497          case SUMA_CMAP_ROI128:
03498             {
03499                /* a large colormap for lots of ROI drawing */
03500                Ncols = 128;
03501                NFid = 6;
03502                
03503                Fiducials = (float **)SUMA_allocate2D(NFid, 3, sizeof(float));
03504                Nind = (int *) SUMA_calloc (NFid, sizeof (int));
03505                
03506                if (!Fiducials || !Nind) {
03507                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials or Nind.\n", FuncName);
03508                   SUMA_RETURN (NULL);
03509                }
03510                
03511                /* create the fiducial colors */
03512                k = 0;
03513                Fiducials[k][0] = 1.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0; Nind[k] = 0; ++k; 
03514                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0; Nind[k] = 25; ++k;
03515                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0; Fiducials[k][2] = 1.0; Nind[k] = 50; ++k;
03516                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; Nind[k] = 75; ++k;
03517                Fiducials[k][0] = 0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 1; Nind[k] = 100; ++k;
03518                Fiducials[k][0] = 1; Fiducials[k][1] = 0; Fiducials[k][2] = 1; Nind[k] = 127; ++k;
03519                
03520                
03521                /* generate colormap */
03522                CM = SUMA_MakeColorMap_v2 (Fiducials, k, Nind, NOPE, SUMA_StandardMapName(mapcode,&nc));
03523                
03524                /* free Fiducials & Nind*/
03525                SUMA_free2D((char **)Fiducials, k);
03526                SUMA_free(Nind);
03527                
03528                if (!CM) {
03529                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03530                   SUMA_RETURN (NULL);   
03531                }
03532                break;
03533             
03534             }
03535          
03536          case SUMA_CMAP_ROI64:
03537             {
03538                /* a large colormap for lots of ROI drawing */
03539                Ncols = 64;
03540                NFid = 6;
03541                
03542                Fiducials = (float **)SUMA_allocate2D(NFid, 3, sizeof(float));
03543                Nind = (int *) SUMA_calloc (NFid, sizeof (int));
03544                
03545                if (!Fiducials || !Nind) {
03546                   fprintf (SUMA_STDERR,"Error %s: Failed to allocate for Fiducials or Nind.\n", FuncName);
03547                   SUMA_RETURN (NULL);
03548                }
03549                
03550                /* create the fiducial colors */
03551                k = 0;
03552                Fiducials[k][0] = 1.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0; Nind[k] = 0; ++k; 
03553                Fiducials[k][0] = 0.0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 0; Nind[k] = 12; ++k;
03554                Fiducials[k][0] = 0.0; Fiducials[k][1] = 0; Fiducials[k][2] = 1.0; Nind[k] = 25; ++k;
03555                Fiducials[k][0] = 1.0; Fiducials[k][1] = 0.0; Fiducials[k][2] = 0.0; Nind[k] = 33; ++k;
03556                Fiducials[k][0] = 0; Fiducials[k][1] = 1.0; Fiducials[k][2] = 1; Nind[k] = 50; ++k;
03557                Fiducials[k][0] = 1; Fiducials[k][1] = 0; Fiducials[k][2] = 1; Nind[k] = 63; ++k;
03558                
03559                
03560                /* generate colormap */
03561                CM = SUMA_MakeColorMap_v2 (Fiducials, k, Nind, NOPE, SUMA_StandardMapName(mapcode,&nc));
03562                
03563                /* free Fiducials & Nind*/
03564                SUMA_free2D((char **)Fiducials, k);
03565                SUMA_free(Nind);
03566                
03567                if (!CM) {
03568                   fprintf (SUMA_STDERR,"Error %s: Failed to create CM.\n", FuncName);
03569                   SUMA_RETURN (NULL);   
03570                }
03571                break;
03572             
03573             }
03574             
03575          default:
03576             fprintf (SUMA_STDERR,"Error %s: Unrecognized color map name.\n", FuncName);
03577             SUMA_RETURN (NULL);
03578       
03579       }
03580       
03581       SUMA_RETURN (CM);
03582    }

SUMA_Boolean SUMA_Interpret_AFNIColor char *    Name,
float    RGB[3]
 

turns a color defined by it's Xname or AFNI Hex formulation into good old RGB

  • The function is not particularly efficient for parsing numerous Xnamed colors...

Definition at line 7254 of file SUMA_Color.c.

References cmap, dpy, SUMA_CommonFields::isGraphical, LocalHead, r, SUMA_Boolean, SUMA_ENTRY, SUMA_get_fallbackResources(), and SUMA_RETURN.

Referenced by SUMA_AFNI_Extract_Colors(), and SUMA_Get_AFNI_Default_Color_Maps().

07255 {
07256    static char FuncName[]={"SUMA_Interpret_AFNIColor"};
07257    char *vargv[1]={ "SCALE_TO_MAP" };
07258    int cargc = 1;
07259    int r, g, b;
07260    char stmp[10];   
07261    XVisualInfo vtmp, *vislist;
07262    XtAppContext app; 
07263    Widget tl;
07264    Display *dpy=NULL;
07265    XColor color_closest, color_exact;
07266    Colormap cmap;
07267    SUMA_Boolean LocalHead = NOPE;
07268    
07269    SUMA_ENTRY;
07270    
07271       if (Name[0] == '#') { /* explicitly defined */
07272          sprintf(stmp,"0x%c%c", Name[1], Name[2]);
07273          sscanf (stmp, "%x", &r);
07274          sprintf(stmp,"0x%c%c", Name[3], Name[4]);
07275          sscanf (stmp, "%x", &g);
07276          sprintf(stmp,"0x%c%c", Name[5], Name[6]);
07277          sscanf (stmp, "%x", &b);
07278          RGB[0] = (float)r/255.0;
07279          RGB[1] = (float)g/255.0;
07280          RGB[2] = (float)b/255.0;
07281          
07282       } else { /* named */
07283          /* XtAppInitialize (at least on mac osx) forces the application to quit if display cannot be opened
07284          So you must decide ahead of time whether to call it or not! */
07285          if (SUMAg_CF->isGraphical) {
07286             tl = XtAppInitialize(NULL, "ScaleToMap", NULL, 0, &cargc, vargv,
07287                   SUMA_get_fallbackResources(), NULL, 0);
07288             dpy = XtDisplay(tl);
07289             cmap = DefaultColormap(dpy, DefaultScreen(dpy));
07290 
07291             XParseColor(dpy, cmap, Name, &color_exact);
07292 
07293             /* You need to divide by color_exact.red ,green and blue by 257
07294             to bring the numbers in the 0..255 range as listed in the rgb.txt file */
07295             RGB[0] = (float)color_exact.red/255.0/257.0;
07296             RGB[1] = (float)color_exact.green/255.0/257.0;
07297             RGB[2] = (float)color_exact.blue/255.0/257.0;
07298 
07299             XFreeColormap(dpy, cmap);
07300             XtDestroyWidget(tl);
07301          } else {
07302             if (LocalHead) fprintf(SUMA_STDERR,"%s: \n"
07303                                           "Xcolor %s cannot be resolved without \n"
07304                                           "trying to open X display.\n"
07305                                           "Returning color 0.5 0.5 0.5", FuncName, Name);
07306             RGB[0] = RGB[1] = RGB[2] = 0.5;
07307          }
07308       }
07309    
07310 
07311    if (LocalHead) {
07312       fprintf (SUMA_STDERR,"%s: %s = %f %f %f\n", 
07313                         FuncName,  Name, RGB[0], RGB[1], RGB[2]);
07314    }
07315    
07316    SUMA_RETURN (YUP);
07317 }

SUMA_Boolean SUMA_iRGB_to_OverlayPointer SUMA_SurfaceObject   SO,
char *    Name,
SUMA_OVERLAY_PLANE_DATA   sopd,
int *    PlaneInd,
SUMA_DO   dov,
int    N_dov,
DList   DsetList
 

A function that looks up an overlay plane by its name. If the plane is found its index is returned, otherwise a new one is created. The function also sets up pointers to that plane for all related surfaces in dov and places node colors in that plane.

Parameters:
SO  (SUMA_SurfaceObject *) Surface Object
Name  (char *) Name of color plane
sopd  (SUMA_OVERLAY_PLANE_DATA *) Data to put in overlay plane
PlaneInd  (int *) index of created or found color plane (that's set by the function )
dov  (SUMA_DO *) vector of displayable objects
N_dov  (int ) number of displayable objects

Definition at line 6081 of file SUMA_Color.c.

References a, SUMA_OVERLAY_PLANE_DATA::b, SUMA_SCALE_TO_MAP_OPT::BrightFact, SUMA_OVERLAYS::cmapname, COLP_N_NODEDEF, SUMA_OVERLAYS::DimFact, SUMA_OVERLAY_PLANE_DATA::DimFact, SUMA_DSET::dnel, SUMA_OVERLAYS::dset_link, SUMA_OVERLAYS::FullList, SUMA_OVERLAY_PLANE_DATA::g, SUMA_OVERLAY_PLANE_DATA::GlobalOpacity, SUMA_OVERLAYS::GlobalOpacity, SUMA_OVERLAY_PLANE_DATA::i, i, SUMA_SurfaceObject::idcode_str, SUMA_OVERLAY_PLANE_DATA::isBackGrnd, SUMA_OVERLAYS::isBackGrnd, SUMA_SurfaceObject::Label, SUMA_SurfaceObject::LocalDomainParentID, LocalHead, SUMA_OVERLAY_PLANE_DATA::N, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::N_Overlays, SUMA_OVERLAYS::OptScl, SUMA_SurfaceObject::Overlays, SUMA_OVERLAY_PLANE_DATA::r, r, SES_Afni, SUMA_OVERLAY_PLANE_DATA::Show, SUMA_OVERLAYS::Show, SOPT_ibbb, SOPT_ifff, SUMA_OVERLAY_PLANE_DATA::Source, SUMA_AddDsetNelCol(), SUMA_AddNewPlane(), SUMA_append_string(), SUMA_Boolean, SUMA_ColorizePlane(), SUMA_copy_string(), SUMA_CreateDsetPointer(), SUMA_CreateOverlayPointer(), SUMA_ENTRY, SUMA_Fetch_OverlayPointer(), SUMA_free, SUMA_FreeOverlayPointer(), SUMA_GetDsetColIndex(), SUMA_InsertDsetPointer(), SUMA_isLocalDomainParent(), SUMA_LH, SUMA_NODE_B, SUMA_NODE_G, SUMA_NODE_INDEX, SUMA_NODE_R, SUMA_NODE_RGB, SUMA_RETURN, SUMA_SL_Crit, SUMA_SL_Err, SUMA_SL_Warn, SUMA_SLP_Err, SUMA_SLP_Warn, SUMA_OVERLAY_PLANE_DATA::Type, NI_element::vec, and NI_element::vec_filled.

Referenced by SUMA_LoadColorPlaneFile(), SUMA_Paint_SO_ROIplanes(), and SUMA_process_NIML_data().

06085 {
06086    static char FuncName[]={"SUMA_iRGB_to_OverlayPointer"}, stmp[500];
06087    char *DsetName_tmp=NULL;
06088    int i, OverInd = -1, i_max, wrn_cnt = 0, i3 = 0, N_NodeDef = -1, *NodeDef = NULL;
06089    SUMA_SurfaceObject *SO2 = NULL;
06090    SUMA_OVERLAYS *Overlay=NULL;
06091    SUMA_DSET *dset = NULL;
06092    SUMA_Boolean LocalHead = NOPE;
06093    
06094    SUMA_ENTRY;
06095 
06096       SUMA_LH("Fetching Overlay Pointer");
06097       /* if plane exists use it, else create a new one on the mappable surface */
06098       if (!SUMA_Fetch_OverlayPointer (SO->Overlays, SO->N_Overlays, Name, &OverInd)) {
06099          SUMA_LH("pointer not found");
06100          /* overlay plane not found, create a new one on the mappable surface*/
06101          if (!SUMA_isLocalDomainParent(SO)) {
06102             if (sopd->Source == SES_Afni) {
06103                /* unexpected, surfaces coming from AFNI with a map should be a local domain parent */
06104                fprintf(SUMA_STDERR,"Error %s: Surface %s (ID: %s) received from AFNI is not a local domain parent.\n", FuncName, SO->Label, SO->idcode_str);
06105                SUMA_RETURN(NOPE);
06106             } else {
06107                SUMA_SL_Warn ("Placing colors on surface \nnot a local domain parent.\nCase not tested.");
06108             }
06109          } 
06110          
06111          DsetName_tmp = SUMA_append_string(Name, SO->LocalDomainParentID);
06112          dset = SUMA_CreateDsetPointer (DsetName_tmp, 
06113                                         SUMA_NODE_RGB,
06114                                         NULL,
06115                                         SO->idcode_str,
06116                                         SO->N_Node);   /* first create a dataset that will go with that colorplane */   
06117          SUMA_free(DsetName_tmp); DsetName_tmp = NULL;
06118          /* insert that element into DaList */
06119          if (!SUMA_InsertDsetPointer(dset, DsetList)) {
06120             SUMA_SL_Err("Failed to insert dset into list");
06121             SUMA_RETURN(NOPE);
06122          }
06123          /* We'll be using NodeDef here so begin by allocating space for the various entries */
06124          SUMA_AddDsetNelCol (dset, "node index", SUMA_NODE_INDEX, NULL, NULL, 1);
06125          SUMA_AddDsetNelCol (dset, "red", SUMA_NODE_R, NULL, NULL, 1);
06126          SUMA_AddDsetNelCol (dset, "green", SUMA_NODE_G, NULL, NULL, 1);
06127          SUMA_AddDsetNelCol (dset, "blue", SUMA_NODE_B, NULL, NULL, 1);
06128 
06129          Overlay = SUMA_CreateOverlayPointer (SO->N_Node, Name, dset, SO->idcode_str);
06130          if (!Overlay) {
06131             fprintf (SUMA_STDERR, "Error %s: Failed in SUMA_CreateOverlayPointer.\n", FuncName);
06132             SUMA_RETURN(NOPE);
06133          } 
06134          
06135          
06136          /* set up some defaults for the overlap plane */
06137          Overlay->Show = sopd->Show;
06138          Overlay->GlobalOpacity = sopd->GlobalOpacity;
06139          Overlay->isBackGrnd = sopd->isBackGrnd;
06140          Overlay->OptScl->BrightFact = sopd->DimFact;
06141          OverInd = SO->N_Overlays; 
06142 
06143          /* Add this plane to SO->Overlays */
06144          if (!SUMA_AddNewPlane (SO, Overlay, dov, N_dov, 0)) {
06145             SUMA_SL_Crit("Failed in SUMA_AddNewPlane");
06146             SUMA_FreeOverlayPointer(Overlay);
06147             SUMA_RETURN (NOPE);
06148          }
06149 
06150          
06151       }else {
06152          SUMA_LH("Pointer found");
06153       }
06154       
06155       if (LocalHead) fprintf (SUMA_STDERR, "%s: OverInd = %d, Loading colors to Overlay Plane...\n", FuncName, OverInd);
06156       if (sopd->N > SO->N_Node) {
06157          sprintf(stmp,"Number of nodes in colorplane (%d)\n" \
06158                       "is larger than number of nodes in surface (%d)\n" \
06159                       "Proceed if you know what you're doing.\n" \
06160                       "Data from high node indices will be ignored.",  
06161                   sopd->N, SO->N_Node);
06162          SUMA_SLP_Warn(stmp);
06163          i_max = SO->N_Node;
06164       } else {
06165          i_max = sopd->N;
06166       }
06167       
06168       SO->Overlays[OverInd]->DimFact = sopd->DimFact;
06169       SO->Overlays[OverInd]->cmapname = SUMA_copy_string("explicit"); /* explict color definition in data */
06170       SO->Overlays[OverInd]->FullList = 0; /*!< This type of planes is not usually a full list because it has the nodes defined*/
06171       
06172       /* Now put the colors in the overlay plane */
06173       if (LocalHead) fprintf (SUMA_STDERR,
06174                               "%s: %d node colors are to be inserted.\n",
06175                               FuncName, i_max);
06176                                     
06177       COLP_N_NODEDEF(SO->Overlays[OverInd]) = i_max; /* set the number of nodes filled IN THE OVERLAY PLANE*/
06178       SO->Overlays[OverInd]->dset_link->dnel->vec_filled = i_max; /* set the number of nodes filled IN THE DSET, For this
06179                                                       type of dsets, the N_NodeDef is the same for both OVERLAY
06180                                                       and DSET*/
06181       if (COLP_N_NODEDEF(SO->Overlays[OverInd])) {
06182          int *iv, N_i,*Nv; 
06183          float *Rv, *Gv, *Bv; 
06184          SUMA_DSET *dset;
06185          dset = SO->Overlays[OverInd]->dset_link;
06186          /* find the columns you need to fill. You can't use SUMA_FillNelCol directly because
06187          columns (vectors) are of different types */
06188          iv = SUMA_GetDsetColIndex (dset, SUMA_NODE_INDEX, &N_i);
06189          if (N_i != 1) { SUMA_SL_Err("Failed to find one column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
06190          Nv = (int *)dset->dnel->vec[iv[0]]; SUMA_free(iv); iv = NULL; 
06191          iv = SUMA_GetDsetColIndex (dset, SUMA_NODE_R, &N_i);
06192          if (N_i != 1) { SUMA_SL_Err("Failed to find one column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
06193          Rv = (float *)dset->dnel->vec[iv[0]];SUMA_free(iv); iv = NULL; 
06194          iv = SUMA_GetDsetColIndex (dset, SUMA_NODE_G, &N_i);
06195          if (N_i != 1) { SUMA_SL_Err("Failed to find one column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
06196          Gv = (float *)dset->dnel->vec[iv[0]];SUMA_free(iv); iv = NULL; 
06197          iv = SUMA_GetDsetColIndex (dset, SUMA_NODE_B, &N_i);
06198          if (N_i != 1) { SUMA_SL_Err("Failed to find one column."); SUMA_free(iv); SUMA_RETURN(NOPE); }
06199          Bv = (float *)dset->dnel->vec[iv[0]];SUMA_free(iv); iv = NULL; 
06200          /* Now store these colors into the dataset */
06201          switch (sopd->Type) {
06202             case SOPT_ibbb:
06203                {
06204                   int *inel=NULL;
06205                   byte *r=NULL, *g=NULL, *b=NULL, *a=NULL;
06206                   
06207                   inel = (int *)sopd->i;
06208                   r = (byte *)sopd->r;
06209                   g = (byte *)sopd->g;
06210                   b = (byte *)sopd->b;
06211                   for (i=0; i < i_max; ++i) {
06212                      /*fprintf(SUMA_STDERR,"Node %d: r%d, g%d, b%d\n", inel[i], r[i], g[i], b[i]);*/
06213                      if (SO->N_Node > inel[i]) {
06214                         Nv[i] = inel[i];
06215                         Rv[i] = (float)(r[i]) / 255.0;
06216                         Gv[i] = (float)(g[i]) / 255.0;
06217                         Bv[i] = (float)(b[i]) / 255.0;
06218                      } else {
06219                         if (!wrn_cnt) {
06220                            sprintf(stmp, "Color plane includes node indices (%d at %d)\n"   \
06221                                          "that are >= number of nodes in surface (%d).\n"\
06222                                          "Other similar warnings will be muted.", inel[i], i, SO->N_Node); 
06223                            SUMA_SLP_Warn(stmp);
06224                         }
06225                         ++wrn_cnt;  
06226                      }
06227                   }
06228                }
06229                break;
06230             case SOPT_ifff:
06231                {
06232                   int *inel=NULL;
06233                   float *r=NULL, *g=NULL, *b=NULL, *a=NULL;
06234                   
06235                   inel = (int *)sopd->i;
06236                   r = (float *)sopd->r;
06237                   g = (float *)sopd->g;
06238                   b = (float *)sopd->b;
06239                   for (i=0; i < i_max; ++i) {
06240                      /*fprintf(SUMA_STDERR,"Node %d: r%f, g%f, b%f\n", inel[i], r[i], g[i], b[i]);*/
06241                      if (SO->N_Node > inel[i]) {
06242                         Nv[i] = inel[i];
06243                         Rv[i] = (float)(r[i]) ;
06244                         Gv[i] = (float)(g[i]) ;
06245                         Bv[i] = (float)(b[i]) ;
06246                      } else {
06247                         if (!wrn_cnt) {
06248                            SUMA_SLP_Warn("Color plane includes node indices\n"   \
06249                                          "that are >= number of nodes in surface.\n");
06250                         }
06251                         ++wrn_cnt;  
06252                      }
06253                   }
06254                }
06255                break;
06256             default:
06257                SUMA_SLP_Err("Unknown color plane type");
06258                SUMA_RETURN(NOPE);
06259                break;
06260          }
06261       }
06262       
06263       /* Now you want to create the colors of that plane based on the data in dset */
06264       if (!SUMA_ColorizePlane (SO->Overlays[OverInd])) {
06265          SUMA_SLP_Err("Failed to colorize plane.\n");
06266          SUMA_RETURN(NOPE);
06267       }
06268       
06269       /* store overlay plane index here, OverInd will get mango-ed further down */
06270       if (LocalHead) fprintf (SUMA_STDERR, "%s: OverInd = %d. Returning.\n", FuncName, OverInd);
06271       *PlaneInd = OverInd;
06272 
06273    SUMA_RETURN (YUP);
06274 
06275 }

SUMA_Boolean SUMA_isDsetColumn_inferred SUMA_DSET   dset,
int    icol
 

Definition at line 6549 of file SUMA_Color.c.

References LocalHead, SUMA_Boolean, SUMA_DsetColLabelCopy(), SUMA_ENTRY, SUMA_free, SUMA_LH, and SUMA_RETURN.

Referenced by SUMA_MaskDsetByClustList().

06550 {
06551    static char FuncName[]={"SUMA_isDsetColumn_inferred"};
06552    char *lblcp=NULL;
06553    SUMA_Boolean LocalHead = NOPE;
06554    SUMA_ENTRY;
06555    
06556    lblcp = SUMA_DsetColLabelCopy(dset, icol, 0);
06557    
06558    SUMA_LH(lblcp);
06559    if (lblcp) {
06560       if (strstr(lblcp, "(inferred)")) SUMA_RETURN(YUP);   
06561    }
06562    SUMA_free(lblcp);
06563    SUMA_RETURN(NOPE);
06564 }

SUMA_Boolean SUMA_isOverlayOfSO SUMA_SurfaceObject   SO,
SUMA_OVERLAYS   Plane
 

Is a color overlay plane registered in SO

Definition at line 5686 of file SUMA_Color.c.

References i, LocalHead, SUMA_SurfaceObject::N_Overlays, SUMA_SurfaceObject::Overlays, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_AddNewPlane(), SUMA_RemoveCoordBias(), SUMA_SetCoordBias(), and SUMA_TransferCoordBias().

05687 {
05688    static char FuncName[]={"SUMA_isOverlayOfSO"};
05689    int i;
05690    SUMA_Boolean LocalHead = NOPE;
05691    
05692    SUMA_ENTRY; 
05693 
05694    for (i=0; i< SO->N_Overlays; ++i) if (SO->Overlays[i] == Plane) SUMA_RETURN(YUP);
05695    
05696    SUMA_RETURN(NOPE);
05697 }

SUMA_COLOR_MAP* SUMA_Linearize_Color_Map SUMA_COLOR_MAP   SM,
int    N_lin
 

function that turns a non-linear color map into a linear one The larger the number of colors in the linear color map, the close the approximation to the non-linear map.

Parameters:
SM  (SUMA_COLOR_MAP*) a non-linear colormap (i.e. SM->frac != NULL)
N_Lin  (int) number of colors to use in the linear version of the map if N_Lin = -1, N_Lin is set to 1024
Returns:
LSM (SUMA_COLOR_MAP*) linear version of the colormap NULL if SM is already linear NULL if SM is NULL

Definition at line 1159 of file SUMA_Color.c.

References SUMA_COLOR_MAP::cname, SUMA_COLOR_MAP::frac, i, LocalHead, SUMA_COLOR_MAP::M, SUMA_COLOR_MAP::N_Col, SUMA_COLOR_MAP::Name, SUMA_COLOR_MAP::Sgn, SUMA_COLOR_MAP::SO, SUMA_allocate2D(), SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_free, SUMA_malloc, SUMA_RETURN, and SUMA_S_Err.

Referenced by SUMA_Cmap_To_SO(), SUMA_ScaleToMap(), and SUMA_ScaleToMap_alaAFNI().

01160 {
01161    static char FuncName[]={"SUMA_Linearize_Color_Map"};
01162    SUMA_COLOR_MAP* LSM = NULL;
01163    int ilin = 0, i = 0, ilin_stp = -1; 
01164    SUMA_Boolean LocalHead = NOPE;
01165    
01166    SUMA_ENTRY;
01167 
01168    if (!SM) {
01169       SUMA_S_Err("NULL color map");
01170       SUMA_RETURN(LSM);
01171    }
01172    
01173    if (!SM->frac) {
01174       SUMA_S_Err("NULL SM->frac!\nMap is linear");
01175       SUMA_RETURN(LSM);
01176    }
01177    
01178    if (N_lin < 0) N_lin = 2048;     /* set default linear map length */
01179    
01180    if (!N_lin) {
01181       SUMA_S_Err("N_lin = 0");
01182       SUMA_RETURN(LSM);
01183    }
01184    
01185    /* allocate for new map */
01186    LSM = (SUMA_COLOR_MAP *)SUMA_malloc(sizeof(SUMA_COLOR_MAP));
01187    if (LSM == NULL) {
01188       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for LSM.\n", FuncName);
01189       SUMA_RETURN (NULL);
01190    }
01191    LSM->SO = NULL;
01192    
01193    LSM->Name = (char *)SUMA_calloc(strlen(SM->Name)+10, sizeof(char));
01194    if (LSM->Name == NULL) {
01195       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for LSM->Name.\n", FuncName);
01196       SUMA_free(LSM);
01197       SUMA_RETURN (NULL);
01198    }
01199    sprintf(LSM->Name, "%s_lin",SM->Name); 
01200    LSM->N_Col = N_lin;
01201    LSM->frac = NULL;
01202    LSM->cname = NULL;
01203    LSM->Sgn = SM->Sgn;
01204                                        
01205    LSM->M = (float **)SUMA_allocate2D (LSM->N_Col, 3, sizeof(float));
01206    if (LSM->M == NULL) {
01207       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for LSM->M.\n", FuncName);
01208       SUMA_free(LSM->Name);
01209       SUMA_free(LSM);
01210       SUMA_RETURN (NULL);
01211    }
01212    
01213    ilin = 0;
01214    for (i=0; i < SM->N_Col; ++i) {
01215       if (LSM->Sgn >= 0) {
01216          ilin_stp = (int)(ceil((double)SM->frac[i] * (double)LSM->N_Col)) - 1;
01217       } else {
01218          ilin_stp = (int)(ceil( (1.0 + (double)SM->frac[i]) * (double)LSM->N_Col/2 ) ) - 1;
01219       }
01220       while (ilin < ilin_stp) {
01221          LSM->M[ilin][0] = SM->M[i][0];
01222          LSM->M[ilin][1] = SM->M[i][1];
01223          LSM->M[ilin][2] = SM->M[i][2];
01224          ++ilin; 
01225       }
01226    }
01227    
01228    /* copy last value */
01229    LSM->M[LSM->N_Col-1][0] = SM->M[SM->N_Col-1][0];
01230    LSM->M[LSM->N_Col-1][1] = SM->M[SM->N_Col-1][1];
01231    LSM->M[LSM->N_Col-1][2] = SM->M[SM->N_Col-1][2];
01232    
01233    if (LocalHead) {
01234       for (i=0; i < LSM->N_Col; ++i) {
01235          fprintf (SUMA_STDOUT,"%d:\t%f\t%f\t%f\n", i, LSM->M[i][0], LSM->M[i][1], LSM->M[i][2]); 
01236       }
01237       fprintf (SUMA_STDOUT,"%s: ilin_stp = %d\n", FuncName, ilin_stp); 
01238    }
01239    
01240    SUMA_RETURN(LSM);
01241 }

SUMA_Boolean SUMA_ListOrderToPlaneOrder DList   listop
 

sets the values of PlaneOrder to reflect the location of the color planes in list

Definition at line 5576 of file SUMA_Color.c.

References DListElmt_::data, dlist_head, dlist_is_tail, i, SUMA_OVERLAYS::isBackGrnd, DListElmt_::next, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_OVERLAYS::PlaneOrder, DList_::size, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_MovePlaneDown(), SUMA_MovePlaneUp(), and SUMA_OverlaysToOrderedList().

05577 {
05578    static char FuncName[]={"SUMA_ListOrderToPlaneOrder"};
05579    SUMA_OVERLAY_LIST_DATUM *OvD = NULL;
05580    int i, fg_shift = 0;
05581    DListElmt *Elmop=NULL;
05582 
05583    SUMA_ENTRY;
05584 
05585    /* First pass, do background */
05586    if (listop->size) {
05587       Elmop = NULL;
05588       i = 0;
05589       do {
05590          if (!Elmop) Elmop = dlist_head(listop);
05591          else Elmop = Elmop->next;
05592          OvD = (SUMA_OVERLAY_LIST_DATUM *)Elmop->data;
05593          if (OvD->Overlay->isBackGrnd) {
05594             OvD->Overlay->PlaneOrder = i;
05595             ++i;
05596          }
05597       } while (!dlist_is_tail(Elmop));
05598    }
05599    
05600    /* second pass, do foreground */
05601    if (listop->size) {
05602       Elmop = NULL;
05603       i = 0;
05604       do {
05605          if (!Elmop) Elmop = dlist_head(listop);
05606          else Elmop = Elmop->next;
05607          OvD = (SUMA_OVERLAY_LIST_DATUM *)Elmop->data;
05608          if (!OvD->Overlay->isBackGrnd) {
05609             OvD->Overlay->PlaneOrder = i;
05610             ++i;
05611          }
05612       } while (!dlist_is_tail(Elmop));
05613    }
05614    
05615 
05616    SUMA_RETURN(YUP);
05617 }

void SUMA_LoadColorPlaneFile char *    filename,
void *    data
 

Loads a color plane file and adds it to a surface's list of colorplanes.

Parameters:
dlg  (SUMA_SELECTION_DIALOG_STRUCT *) struture from selection dialogue

Definition at line 6907 of file SUMA_Color.c.

References SUMA_OVERLAY_PLANE_DATA::a, SUMA_IRGB::b, SUMA_OVERLAY_PLANE_DATA::b, SUMA_X_SurfCont::curColPlane, SUMA_OVERLAY_PLANE_DATA::DimFact, SUMA_CommonFields::DsetList, SUMA_IRGB::g, SUMA_OVERLAY_PLANE_DATA::g, SUMA_OVERLAY_PLANE_DATA::GlobalOpacity, SUMA_IRGB::i, SUMA_OVERLAY_PLANE_DATA::i, SUMA_OVERLAY_PLANE_DATA::isBackGrnd, SUMA_LIST_WIDGET::isShaded, SUMA_SurfaceObject::Label, LocalHead, SUMA_IRGB::N, SUMA_OVERLAY_PLANE_DATA::N, SUMA_SurfaceObject::Overlays, SUMA_IRGB::r, SUMA_OVERLAY_PLANE_DATA::r, SES_Suma, SUMA_OVERLAY_PLANE_DATA::Show, SOPT_ifff, SUMA_OVERLAY_PLANE_DATA::Source, SUMA_Boolean, SUMA_ENTRY, SUMA_filexists(), SUMA_Free_IRGB(), SUMA_InitializeColPlaneShell(), SUMA_iRGB_to_OverlayPointer(), SUMA_LH, SUMA_Read_IRGB_file(), SUMA_RefreshDsetList(), SUMA_RemixRedisplay(), SUMA_RETURNe, SUMA_SLP_Err, SUMAg_N_DOv, SUMA_SurfaceObject::SurfCont, SUMA_X_SurfCont::SwitchDsetlst, and SUMA_OVERLAY_PLANE_DATA::Type.

06908 {
06909    static char FuncName[]={"SUMA_LoadColorPlaneFile"};
06910    SUMA_SurfaceObject *SO = NULL;
06911    SUMA_OVERLAY_PLANE_DATA sopd;
06912    SUMA_IRGB *irgb=NULL;
06913    int OverInd = -1;
06914    DList *list=NULL;
06915    SUMA_LIST_WIDGET *LW=NULL;
06916    SUMA_Boolean LocalHead = NOPE;
06917       
06918    SUMA_ENTRY;
06919 
06920    if (!data) {
06921       SUMA_SLP_Err("Null data"); 
06922       SUMA_RETURNe;
06923    }
06924    
06925    SO = (SUMA_SurfaceObject *)data;
06926    
06927    if (LocalHead) {
06928       fprintf (SUMA_STDERR,"%s: Received request to load %s for surface %s.\n", FuncName, filename, SO->Label);
06929    }
06930 
06931    /* find out if file exists and how many values it contains */
06932    if (!SUMA_filexists(filename)) {
06933       SUMA_SLP_Err("File not found");
06934       SUMA_RETURNe;
06935    }
06936 
06937    irgb = SUMA_Read_IRGB_file(filename);
06938    if (!irgb) {
06939       SUMA_SLP_Err("Failed to read file.");
06940       SUMA_RETURNe;
06941    }
06942 
06943    sopd.N = irgb->N;
06944    sopd.Type = SOPT_ifff;
06945    sopd.Source = SES_Suma;
06946    sopd.GlobalOpacity = 0.3;
06947    sopd.isBackGrnd = NOPE;
06948    sopd.Show = YUP;
06949    /* dim colors from maximum intensity to preserve surface shape highlights, division by 255 is to scale color values between 1 and 0 */
06950    sopd.DimFact = 0.5;
06951    sopd.i = (void *)irgb->i;
06952    sopd.r = (void *)irgb->r;
06953    sopd.g = (void *)irgb->g;
06954    sopd.b = (void *)irgb->b;
06955    sopd.a = NULL;
06956 
06957    if (!SUMA_iRGB_to_OverlayPointer (  SO, filename, &sopd, &OverInd, 
06958                                        SUMAg_DOv, SUMAg_N_DOv, SUMAg_CF->DsetList)) {
06959       SUMA_SLP_Err("Failed to fetch or create overlay pointer.");
06960       SUMA_RETURNe;
06961    }
06962 
06963    /* values were copied, dump structure */
06964    irgb = SUMA_Free_IRGB(irgb);  
06965 
06966    /* See note before similar line in SUMA_LoadDsetFile */
06967    SO->SurfCont->curColPlane = SO->Overlays[OverInd]; 
06968 
06969    if (!SUMA_RemixRedisplay (SO)) {
06970       SUMA_RETURNe;
06971    }
06972   
06973    SUMA_LH("Refreshing color plane list");            
06974    /*update the list widget if open */
06975    LW = SO->SurfCont->SwitchDsetlst;
06976    if (LW) {
06977       if (!LW->isShaded) SUMA_RefreshDsetList (SO);  
06978    }  
06979    
06980    if (LocalHead) fprintf (SUMA_STDERR,"%s: Updating color plane frame, OverInd=%d\n", 
06981       FuncName, OverInd);
06982    /* update the color plane frame */
06983    if (OverInd >= 0)        
06984       SUMA_InitializeColPlaneShell(SO, SO->Overlays[OverInd]);
06985 
06986    SUMA_RETURNe;
06987 }

void SUMA_LoadDsetFile char *    filename,
void *    data
 

Loads a Dset file and adds it to the list of datasets.

Parameters:
dlg  (SUMA_SELECTION_DIALOG_STRUCT *) struture from selection dialogue

Definition at line 6746 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::bind, SUMA_X_SurfCont::curColPlane, SUMA_DSET::dnel, SUMA_CommonFields::DsetList, SUMA_SCALE_TO_MAP_OPT::find, SUMA_OVERLAYS::GlobalOpacity, SUMA_SurfaceObject::idcode_str, SUMA_SCALE_TO_MAP_OPT::IntRange, SUMA_LIST_WIDGET::isShaded, SUMA_SurfaceObject::Label, SUMA_SurfaceObject::LocalDomainParentID, LocalHead, SUMA_SurfaceObject::N_Overlays, SUMA_DSET::ngr, NI_set_attribute(), SUMA_OVERLAYS::OptScl, SUMA_SurfaceObject::Overlays, SDSET_IDMDOM, SUMA_OVERLAYS::Show, SUMA_AddNewPlane(), SUMA_Boolean, SUMA_ColorizePlane(), SUMA_CreateOverlayPointer(), SUMA_DSET_FORMAT, SUMA_DsetInfo(), SUMA_ENTRY, SUMA_filexists(), SUMA_free, SUMA_FreeDset(), SUMA_FreeOverlayPointer(), SUMA_GetDsetColRange(), SUMA_GuessFormatFromExtension(), SUMA_InitializeColPlaneShell(), SUMA_InsertDsetPointer(), SUMA_isDsetRelated(), SUMA_LH, SUMA_LoadDset(), SUMA_OKassign(), SUMA_RefreshDsetList(), SUMA_RemixRedisplay(), SUMA_RETURNe, SUMA_SetParent_DsetToLoad(), SUMA_SL_Crit, SUMA_SL_Note, SUMA_SLP_Err, SUMAg_N_DOv, SUMA_SurfaceObject::SurfCont, SUMA_X_SurfCont::SwitchDsetlst, SUMA_SCALE_TO_MAP_OPT::tind, and NI_element::vec_len.

06747 {
06748    static char FuncName[]={"SUMA_LoadDsetFile"};
06749    SUMA_SurfaceObject *SO = NULL;
06750    SUMA_OVERLAY_PLANE_DATA sopd;
06751    SUMA_IRGB *irgb=NULL;
06752    int OverInd = -1, lnp=-1, loc[2];
06753    char *np=NULL;
06754    SUMA_DSET_FORMAT form;
06755    DList *list=NULL;
06756    SUMA_LIST_WIDGET *LW=NULL;
06757    SUMA_DSET *dset = NULL;
06758    SUMA_OVERLAYS *NewColPlane = NULL;
06759    SUMA_Boolean LocalHead = NOPE;
06760       
06761    SUMA_ENTRY;
06762 
06763    if (!data) {
06764       SUMA_SLP_Err("Null data"); 
06765       SUMA_RETURNe;
06766    }
06767    
06768    SO = (SUMA_SurfaceObject *)data;
06769    
06770    if (LocalHead) {
06771       fprintf (SUMA_STDERR,"%s: Received request to load %s for surface %s.\n", FuncName, filename, SO->Label);
06772    }
06773 
06774    /* find out if file exists and how many values it contains */
06775    if (!SUMA_filexists(filename)) {
06776       SUMA_SLP_Err("File not found");
06777       SUMA_RETURNe;
06778    }
06779 
06780    /* take a stab at the format */
06781    form = SUMA_GuessFormatFromExtension(filename);
06782    
06783    /* load the dude */
06784    /* first, set the parent ID of the dset to be loaded,
06785    This ID is only used when generating an ID for those dsets
06786    that have no ID attached, like the 1D ones */
06787    if (SO->LocalDomainParentID) SUMA_SetParent_DsetToLoad(SO->LocalDomainParentID);
06788    else if (SO->idcode_str) SUMA_SetParent_DsetToLoad(SO->idcode_str); 
06789    else SUMA_SetParent_DsetToLoad(NULL);  
06790 
06791    dset = SUMA_LoadDset (filename, &form, 0); 
06792    if (!dset) { SUMA_SLP_Err(  "Failed to load dataset.\n"
06793                                  "Make sure file exists\n"
06794                                  "and is of a supported\n"
06795                                  "format."); SUMA_RETURNe; }
06796    SUMA_SetParent_DsetToLoad(NULL);  /* reset the parent surface flag */
06797    
06798    if (LocalHead) {
06799       char *si = NULL;
06800       si = SUMA_DsetInfo(dset, 0);
06801       fprintf(SUMA_STDERR,"%s:\n----------------dset loaded ----------\n%s\n",FuncName, si);
06802       SUMA_free(si); si = NULL;
06803    }
06804    
06805    /* Check if the domain order is SO or not .
06806    If not specified, assign it */
06807    np = SDSET_IDMDOM(dset); if (np) lnp = strlen(np) ; else lnp = 0;
06808    if (!np || lnp == 0) { 
06809       SUMA_SL_Note("dset has no mesh parent, assigning SO");
06810       if (!SUMA_OKassign(dset, SO)) {
06811          SUMA_SLP_Err("Cannot assign dset to SO.\n");
06812          SUMA_FreeDset(dset); dset=NULL;
06813          SUMA_RETURNe;
06814       }
06815       NI_set_attribute(dset->ngr,"Parent_ID", SO->idcode_str);
06816       NI_set_attribute(dset->ngr,"GeomParent_idcode", SO->idcode_str);
06817    } else {
06818       SUMA_SL_Note("dset has a mesh parent, Checking relationship");
06819       if (!SUMA_isDsetRelated(dset, SO)) {
06820          SUMA_SLP_Err("Dset not related to SO");
06821          SUMA_FreeDset(dset); dset=NULL;
06822          SUMA_RETURNe;
06823       }
06824    }
06825    
06826    /* add the dset to the list SUMAg_CF->DsetList*/
06827    if (!SUMA_InsertDsetPointer(dset, SUMAg_CF->DsetList)) {
06828       SUMA_SLP_Err("Failed to add new dset to list");
06829       /* is there not a function to replace a dset yet? */
06830       SUMA_FreeDset(dset); dset = NULL;
06831       SUMA_RETURNe;
06832    }
06833     
06834    /* set up the colormap for this dset */
06835    NewColPlane = SUMA_CreateOverlayPointer (dset->dnel->vec_len, filename, dset, SO->idcode_str);
06836    if (!NewColPlane) {
06837       fprintf (SUMA_STDERR, "Error %s: Failed in SUMA_CreateOverlayPointer.\n", FuncName);
06838       SUMA_RETURNe;
06839    }
06840    
06841    /* The overlay index for that plane is SO->N_Overlays */
06842    OverInd = SO->N_Overlays;
06843    
06844    /* Add this plane to SO->Overlays */
06845    if (!SUMA_AddNewPlane (SO, NewColPlane, SUMAg_DOv, SUMAg_N_DOv, 0)) {
06846       SUMA_SL_Crit("Failed in SUMA_AddNewPlane");
06847       SUMA_FreeOverlayPointer(NewColPlane);
06848       SUMA_FreeDset(dset); dset = NULL;
06849       SUMA_RETURNe;
06850    }
06851    
06852    
06853    /* set the opacity, index column and the range */
06854    NewColPlane->GlobalOpacity = YUP;
06855    NewColPlane->Show = YUP;
06856    NewColPlane->OptScl->find = 0;
06857    NewColPlane->OptScl->tind = 0;
06858    NewColPlane->OptScl->bind = 0;
06859    SUMA_GetDsetColRange(dset, 0, NewColPlane->OptScl->IntRange, loc);
06860    
06861    
06862    /* stick a colormap onto that plane ? */
06863       /* don't worry, there's a default one */
06864    
06865    /* colorize the plane */
06866    SUMA_ColorizePlane(NewColPlane);
06867 
06868    /* SUMA_Show_ColorOverlayPlanes(&NewColPlane, 1, 1); */
06869    
06870    /* set the new curColPlane to the newly loaded plane,
06871    you need to do this before you remix the colors in case
06872    you are only showing the curColPlane.
06873    curColPlane is normally set in  SUMA_InitializeColPlaneShell
06874    but when SO->SurfCont->ShowCurOnly = YUP, curColPlane
06875    is used in the RemixRedisplay function.
06876    NOTE: You can't call SUMA_InitializeColPlaneShell
06877    before remixing because colors are reported in Lbl block
06878     June 28 04*/
06879    SO->SurfCont->curColPlane = SO->Overlays[OverInd]; 
06880         
06881    /* remix-redisplay  for surface */
06882    if (!SUMA_RemixRedisplay (SO)) {
06883       SUMA_RETURNe;
06884    }
06885   
06886    SUMA_LH("Refreshing Dset list");            
06887    /*update the list widget if open */
06888    LW = SO->SurfCont->SwitchDsetlst;
06889    if (LW) {
06890       if (!LW->isShaded) SUMA_RefreshDsetList (SO);  
06891    }  
06892    
06893    if (LocalHead) fprintf (SUMA_STDERR,"%s: Updating Dset frame, OverInd=%d\n", 
06894       FuncName, OverInd);
06895    /* update the Dset frame */
06896    if (OverInd >= 0)        
06897       SUMA_InitializeColPlaneShell(SO, SO->Overlays[OverInd]);
06898 
06899    SUMA_RETURNe;
06900 }

SUMA_COLOR_MAP* SUMA_MakeColorMap float **    Fiducials,
int    Nfid,
int    Ncols,
SUMA_Boolean    SkipLast,
char *    Name
 

This function creates an RGB colormap containing Ncols that vary linearily from the first color in Fiducials to the last.

SM = SUMA_MakeColorMap (Fiducials, N , N_cols, SkipLast, Name)

Parameters:
Fiducials  (float **) N x 3 matrix containing RGB values (range 0..1) of fiducial colours which will be equally spaced on the color map
N  (int) number of fiducial colors in Fiducials
Ncols  (int) total number of colors in the map. You are somewhat restricted in the total number of colours you choose. You must choose a number that allows you to have the same number of colours between successive fiducials. The function will complain if that's not the case
SkipLast  (SUMA_Boolean) if set to NOPE (0), then the last color specified in Fiducials is the last color in M. If set to 1, the last color in M represents the color that would come right before the last one in Fifucials. This last option is usefull when you're crating cyclical color maps where the last color in Fiduciasl is like the first.
Name  (char *) name of colormap \ret SM (SUMA_COLOR_MAP *) see help for SUMA_COLOR_MAP for more info
See also:
based on my matlab function MakeColorMap.m , SUMA_Free_ColorMap , SUMA_MakeColorMap_v2

Definition at line 62 of file SUMA_Color.c.

References SUMA_COLOR_MAP::cname, SUMA_COLOR_MAP::frac, i, SUMA_COLOR_MAP::M, SUMA_COLOR_MAP::N_Col, SUMA_COLOR_MAP::Name, SUMA_COLOR_MAP::Sgn, SUMA_COLOR_MAP::SO, SUMA_allocate2D(), SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_malloc, and SUMA_RETURN.

Referenced by SUMA_GetStandardMap().

00063 {
00064    static char FuncName[]={"SUMA_MakeColorMap"};
00065    float **M, dFid[3];
00066    int i, j, Ninter, Ngap, im, Ncolsgood, Npergap;
00067    SUMA_COLOR_MAP * SM;
00068    
00069    SUMA_ENTRY;
00070    
00071    /* check for bad input */
00072    for (i=0; i < Nfid; ++i) {
00073       for (j=0; j < 3; ++j) {
00074          if (Fiducials[i][j] < 0 || Fiducials[i][j] > 1) {
00075             fprintf (SUMA_STDERR,"Error %s: Fiducial colors must be between 0 & 1 (found %f)\n", FuncName, Fiducials[i][j]);
00076             SUMA_RETURN (NULL);
00077          }
00078       }
00079    }
00080    /* determine the number of intermediate colors */
00081    if (SkipLast) Ninter = Ncols - (Nfid - 1);
00082    else Ninter = Ncols - Nfid;
00083    
00084    Ngap = Nfid - 1;
00085    
00086    /* you must have an equal number of colours in each gap */ 
00087    if (Ninter % Ngap) {
00088       /* bad, sugeest a better number */
00089       if (SkipLast) Ncolsgood = (int)(rint((float)Ninter/Ngap) * Ngap + Nfid + 1);
00090       else Ncolsgood = (int)(rint((float)Ninter/Ngap) * Ngap + Nfid);
00091       
00092       fprintf (SUMA_STDERR,"Error %s: The choice of Ncols does not work with the number\nof fiducial colours.\nTry Ncols = %d\n", \
00093       FuncName, Ncolsgood); 
00094       SUMA_RETURN (NULL);
00095    }
00096    
00097    /* allocate for M */
00098    M = (float **)SUMA_allocate2D (Ncols, 3, sizeof(float));
00099    if (M == NULL) {
00100       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for M.\n", FuncName);
00101       SUMA_RETURN (NULL);
00102    }
00103    
00104    /* start forming M */
00105    im = 0;
00106    Npergap = Ninter / Ngap;
00107    
00108    for (i=0; i < Ngap; ++i) {
00109       dFid[0] = (Fiducials[i+1][0] - Fiducials[i][0])/(Npergap+1);
00110       dFid[1] = (Fiducials[i+1][1] - Fiducials[i][1])/(Npergap+1);
00111       dFid[2] = (Fiducials[i+1][2] - Fiducials[i][2])/(Npergap+1);
00112       /*fprintf (SUMA_STDERR,"%s:  dFid = %f %f %f\n", FuncName, dFid[0], dFid[1] , dFid[2]);*/
00113       
00114       for (j=0; j < Npergap+1; ++ j) {
00115 
00116          if (im < Ncols) {
00117             M[im][0] = Fiducials[i][0] + j*dFid[0];
00118             M[im][1] = Fiducials[i][1] + j*dFid[1];
00119             M[im][2] = Fiducials[i][2] + j*dFid[2];
00120             /*fprintf (SUMA_STDERR,"%s: M[%d][:] = %f %f %f\n", FuncName, im, M[im][0], M[im][1], M[im][2]); */
00121          }
00122                
00123          ++im;
00124       }
00125    }
00126    if (!SkipLast) {
00127       M[im][0] = Fiducials[Ngap][0];
00128       M[im][1] = Fiducials[Ngap][1];
00129       M[im][2] = Fiducials[Ngap][2];
00130    }
00131    
00132    /* package the resutls */
00133    SM = (SUMA_COLOR_MAP *)SUMA_malloc(sizeof(SUMA_COLOR_MAP));
00134    if (SM == NULL) {
00135       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for SM.\n", FuncName);
00136       SUMA_RETURN (NULL);
00137    }
00138    
00139    SM->Name = (char *)SUMA_calloc(strlen(Name)+1, sizeof(char));
00140    if (SM->Name == NULL) {
00141       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for SM->Name.\n", FuncName);
00142       SUMA_RETURN (NULL);
00143    }
00144    sprintf(SM->Name, "%s",Name); 
00145    SM->M = M;
00146    SM->N_Col = Ncols;
00147 
00148    SM->frac = NULL; /* a linear map */
00149    SM->cname = NULL;
00150    SM->Sgn = 0; /* setup for linear maps with no signing, mapping a la old ScaleToMap*/
00151    SM->SO = NULL; /* created when needed */
00152 
00153    SUMA_RETURN (SM);
00154 }

SUMA_COLOR_MAP* SUMA_MakeColorMap_v2 float **    Fiducials,
int    Nfid,
int *    Nint,
SUMA_Boolean    SkipLast,
char *    Name
 

This function creates an RGB colormap containing Ncols that vary linearily from the first color in Fiducials to the last.

SM = SUMA_MakeColorMap_v2 (Fiducials, NFid, Nin , SkipLast, Name)

Parameters:
Fiducials  (float **) NFid x 3 matrix containing RGB values (range 0..1) of fiducial colours which will be equally spaced on the color map
NFid  (int) number of fiducial colors
Nin  (int*) NFid x 1 vector indicating the number of interpolations to perform between successive colors e.g.: Fiducials Nin 1 0 0 2 0 1 0 5 0 0 1 0 The map will start with 1 0 0 then place 2 colors interpolated between 1 0 0 and 0 1 0. The last color of this map is 0 0 1. If the last entry in Nin was 4 then 4 colors are added after 0 0 1 wich are interpolated between the last and 1st color. This is good for cyclical color maps
SkipLast  (SUMA_Boolean) YUP/NOPE keep last color in Fiducials out of the final map
Name  (char *) name of colormap \ret SM (SUMA_COLOR_MAP *) see help for SUMA_COLOR_MAP for more info
See also:
SUMA_Free_ColorMap , SUMA_MakeColorMap

Definition at line 184 of file SUMA_Color.c.

References SUMA_COLOR_MAP::cname, SUMA_COLOR_MAP::frac, i, SUMA_COLOR_MAP::M, SUMA_COLOR_MAP::N_Col, SUMA_COLOR_MAP::Name, SUMA_COLOR_MAP::Sgn, SUMA_COLOR_MAP::SO, SUMA_allocate2D(), SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_malloc, and SUMA_RETURN.

Referenced by SUMA_GetStandardMap().

00185 {
00186    static char FuncName[]={"SUMA_MakeColorMap_v2"};
00187    float **M, dFid[3];
00188    int i, j, im, Ncols;
00189    SUMA_COLOR_MAP * SM;
00190    
00191    SUMA_ENTRY;
00192 
00193    /* check for bad input and calculate the total number of colors*/
00194    if (Nint[0]) {
00195       fprintf (SUMA_STDERR,"Error %s: The index of the first color (%d) must be 0, indexing starts at 0 not 1.\n", FuncName, Nint[0]);
00196       SUMA_RETURN (NULL);
00197    }
00198    for (i=0; i < Nfid; ++i) {
00199       for (j=0; j < 3; ++j) {
00200          if (Fiducials[i][j] < 0 || Fiducials[i][j] > 1) {
00201             fprintf (SUMA_STDERR,"Error %s: Fiducial colors must be between 0 & 1 (found %f)\n", FuncName, Fiducials[i][j]);
00202             SUMA_RETURN (NULL);
00203          }
00204       }
00205    }
00206    
00207    Ncols = Nint[Nfid-1]+1;
00208    
00209    if (SkipLast) Ncols = Ncols - 1;
00210       
00211    /* allocate for M */
00212    M = (float **)SUMA_allocate2D (Ncols, 3, sizeof(float));
00213    if (M == NULL) {
00214       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for M.\n", FuncName);
00215       SUMA_RETURN (NULL);
00216    }
00217    
00218    /* start forming M */
00219    im = 0;   
00220    for (i=0; i < Nfid-1; ++i) {
00221          dFid[0] = (Fiducials[i+1][0] - Fiducials[i][0])/(Nint[i+1]-Nint[i]);
00222          dFid[1] = (Fiducials[i+1][1] - Fiducials[i][1])/(Nint[i+1]-Nint[i]);
00223          dFid[2] = (Fiducials[i+1][2] - Fiducials[i][2])/(Nint[i+1]-Nint[i]);
00224          /*fprintf (SUMA_STDERR,"%s:  dFid = %f %f %f\n", FuncName, dFid[0], dFid[1] , dFid[2]);*/
00225 
00226          for (j=0; j < (Nint[i+1]- Nint[i]); ++ j) {
00227 
00228                M[im][0] = Fiducials[i][0] + j*dFid[0];
00229                M[im][1] = Fiducials[i][1] + j*dFid[1];
00230                M[im][2] = Fiducials[i][2] + j*dFid[2];
00231                /*fprintf (SUMA_STDERR,"%s: M[%d][:] = %f %f %f\n", FuncName, im, M[im][0], M[im][1], M[im][2]); */
00232 
00233             ++im;
00234          }
00235    }
00236    
00237    if (!SkipLast){
00238       M[im][0] = Fiducials[Nfid-1][0];
00239       M[im][1] = Fiducials[Nfid-1][1];
00240       M[im][2] = Fiducials[Nfid-1][2];
00241    }
00242    
00243    /* package the resutls */
00244    SM = (SUMA_COLOR_MAP *)SUMA_malloc(sizeof(SUMA_COLOR_MAP));
00245    if (SM == NULL) {
00246       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for SM.\n", FuncName);
00247       SUMA_RETURN (NULL);
00248    }
00249    
00250    SM->Name = (char *)SUMA_calloc(strlen(Name)+1, sizeof(char));
00251    if (SM->Name == NULL) {
00252       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for SM->Name.\n", FuncName);
00253       SUMA_RETURN (NULL);
00254    }
00255    sprintf(SM->Name, "%s",Name); 
00256    SM->M = M;
00257    SM->N_Col = Ncols;
00258    
00259    SM->frac = NULL; /* a linear map */
00260    SM->cname = NULL;
00261    SM->Sgn = 0; /* setup for linear maps with no signing, mapping a la old ScaleToMap*/
00262    SM->SO = NULL; /* created when needed */
00263    SUMA_RETURN (SM);
00264 }

SUMA_Boolean SUMA_MixColors SUMA_SurfaceViewer   sv
 

ans = SUMA_MixColors (sv); this functions mixes the colors for surface objects that ask for it

Parameters:
sv  (SUMA_SurfaceViewer *)
Returns:
YUP/NOPE

Definition at line 6035 of file SUMA_Color.c.

References SUMA_SurfaceViewer::ColList, i, LocalHead, SUMA_SurfaceViewer::N_ColList, SUMA_DO::OP, SUMA_Boolean, SUMA_ENTRY, SUMA_findSO_inDOv(), SUMA_Overlays_2_GLCOLAR4(), SUMA_RETURN, and SUMAg_N_DOv.

Referenced by SUMA_display().

06036 {
06037    static char FuncName[]={"SUMA_MixColors"};
06038    int i, dov_id;
06039    SUMA_Boolean LocalHead = NOPE;
06040    SUMA_SurfaceObject *SO = NULL;
06041    
06042    SUMA_ENTRY;
06043 
06044    for (i=0; i<sv->N_ColList; ++i) {
06045       if (sv->ColList[i].Remix) {
06046          if (LocalHead) fprintf(SUMA_STDERR, "%s: Mixing colors (%s)...\n", FuncName, sv->ColList[i].idcode_str);
06047          dov_id = SUMA_findSO_inDOv (sv->ColList[i].idcode_str, SUMAg_DOv, SUMAg_N_DOv);
06048          if (dov_id < 0) {
06049             fprintf (SUMA_STDERR,"Error %s: Failed in SUMA_findSO_inDOv.\n", FuncName);
06050             SUMA_RETURN(NOPE);
06051          }
06052          SO = (SUMA_SurfaceObject *)SUMAg_DOv[dov_id].OP;
06053          if (!SUMA_Overlays_2_GLCOLAR4(SO, sv, sv->ColList[i].glar_ColorList)) {
06054             fprintf (SUMA_STDERR,"Error %s: Failed in SUMA_Overlays_2_GLCOLAR4.\n", FuncName);
06055             SUMA_RETURN(NOPE);
06056          }
06057          sv->ColList[i].Remix = NOPE;
06058       }
06059    }   
06060    
06061    SUMA_RETURN (YUP);
06062 
06063 }

SUMA_Boolean SUMA_MixOverlays SUMA_OVERLAYS **    Overlays,
int    N_Overlays,
int *    ShowOverlays,
int    NshowOverlays,
GLfloat *    glcolar,
int    N_Node,
SUMA_Boolean   isColored,
SUMA_Boolean    FILL
 

function to mix overlay plane colors

ans = SUMA_MixOverlays (SUMA_OVERLAYS ** Overlays, int N_Overlays, int *ShowOvelays, int N_ShowOverlays, GLfloat *glcolar, int N_Node, SUMA_Boolean *isColored, SUMA_Boolean FILL)

Overlays (SUMA_OVERLAYS **) a pointer to the vector of overlay planes structure pointers N_Overlays (int) number of overlay plane structures ShowOvelays (int *) vector of Overlay plane indices to be used. The plane indices must be sorted by plane order. N_ShowOverlays (int) number of ovrlay planes used in the mixing glar_ColorList (GLfloat *) pointer to vector (4*SO->N_Node long) that contains the node colors N_Node (int) total number of nodes in Surface NOT in color overlay plane

Parameters:
isColored  (SUMA_Boolean *) N_Node x1 vector containing flags indicating if a node received a color or not
FILL  (SUMA_Boolean) top off nodes that received no color with default gray
See also:
SUMA_Overlays_2_GLCOLAR4

Definition at line 5125 of file SUMA_Color.c.

References SUMA_CommonFields::ColMixMode, COLP_N_NODEDEF, COLP_NODEDEF, i, LocalHead, SUMA_4AML, SUMA_Boolean, SUMA_ENTRY, SUMA_FillBlanks_GLCOLAR4, SUMA_GRAY_NODE_COLOR, SUMA_ORIG_MIX_MODE, SUMA_RETURN, SUMA_RGBv_FGL_AR4op, SUMA_RGBv_FGL_AR4op2, SUMA_RGBv_FGnL_AR4op, SUMA_RGBv_FGnL_AR4op2, SUMA_RGBv_FnGL_AR4op, SUMA_RGBv_FnGnL_AR4op, SUMA_RGBv_PGL_AR4op, SUMA_RGBv_PGL_AR4op2, SUMA_RGBv_PGnL_AR4op, SUMA_RGBv_PGnL_AR4op2, SUMA_RGBv_PnGL_AR4op, SUMA_RGBv_PnGnL_AR4op, and SUMA_SL_Err.

Referenced by SUMA_Overlays_2_GLCOLAR4().

05126 {    
05127    static char FuncName[] = {"SUMA_MixOverlays"};
05128    int i, j;
05129    int *NodeDef, N_NodeDef = -1;
05130    SUMA_Boolean Full, Fill, Locl, Glob;
05131    SUMA_Boolean LocalHead = NOPE; /* local headline debugging messages */   
05132    
05133    SUMA_ENTRY;
05134 
05135    if (!Overlays) {
05136       SUMA_SL_Err("Null Overlays!");
05137       SUMA_RETURN(NOPE);
05138    }
05139    if (!glcolar) {
05140       SUMA_SL_Err("Null glcolar!");
05141       SUMA_RETURN(NOPE);
05142    }
05143    if (!isColored) {
05144       fprintf (SUMA_STDERR, "Error %s: isColored is NULL.\n", FuncName); 
05145       SUMA_RETURN (NOPE);
05146    }
05147    if (!ShowOverlays) {
05148       SUMA_SL_Err("NULL ShowOverlays");
05149       SUMA_RETURN (NOPE);
05150    }
05151    if (!NshowOverlays) { /* nothing to see here */
05152       fprintf (SUMA_STDERR, "Warning %s: Nothing to do.\n", FuncName); 
05153       if (FILL) {
05154          fprintf (SUMA_STDERR, "Warning %s: Filling with blank default color\n", FuncName); 
05155          SUMA_FillBlanks_GLCOLAR4(isColored, N_Node, SUMA_GRAY_NODE_COLOR, SUMA_GRAY_NODE_COLOR, SUMA_GRAY_NODE_COLOR, glcolar);
05156       }
05157       SUMA_RETURN (YUP);
05158    }
05159    
05160    /* start building the node colors */
05161    Full = YUP;
05162    Glob = YUP;
05163    Locl = YUP;
05164    Fill = YUP; 
05165    for (j=0; j<NshowOverlays; ++j) {
05166       Full = YUP;
05167       Glob = YUP;
05168       Locl = YUP;
05169       Fill = YUP; 
05170       
05171       i = ShowOverlays[j];
05172       if (!Overlays[i]) {
05173          fprintf(SUMA_STDERR,"Error %s:\nNULL ShowOverlays[%d]\n", FuncName, i);
05174          SUMA_RETURN (NOPE);
05175       }  
05176      
05177       /* is this a full listing */
05178       if (LocalHead) fprintf (SUMA_STDOUT, "%s: Full listing flag: %d\n", FuncName, Overlays[i]->FullList);
05179       if (Overlays[i]->FullList) {         Fill = NOPE;   /* Full list, no need to fill up unvisited nodes at the end */   } 
05180       else {         Full = NOPE; /* Not a full list */      }
05181       
05182       if (j > 0) { /* opacity plays a role when you are overlaying one plane on top of the other */
05183          /* is this a Global Factor */
05184          if (Overlays[i]->GlobalOpacity < 0.0) {         Glob = NOPE;      }
05185 
05186          /* is this a Local Factor */
05187          if (Overlays[i]->LocalOpacity[0] < 0) {         Locl = NOPE;      }
05188       } else {
05189          Glob = NOPE; Locl = NOPE;
05190       }
05191       
05192       NodeDef = COLP_NODEDEF(Overlays[i]);
05193       N_NodeDef = COLP_N_NODEDEF(Overlays[i]);
05194    
05195 
05196       if (LocalHead) 
05197          fprintf (SUMA_STDOUT,"%s: Building color layer %d Overlay #%d: %s ...\nFull=%d, Glob=%d (Globopacity %f), Locl=%d,Fill=%d\n", \
05198          FuncName, j, i, Overlays[i]->Name, (int)Full, (int)Glob, Overlays[i]->GlobalOpacity, (int)Locl, (int)Fill);
05199       
05200          
05201       /* call the appropriate macro to add the overlay */
05202       if (Full && Glob && Locl) {
05203          if (SUMAg_CF->ColMixMode == SUMA_ORIG_MIX_MODE) {
05204             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling SUMA_RGBv_FGL_AR4op ...\n", FuncName);
05205             /* This macro used to be called: SUMA_RGBmat_FullGlobLoc2_GLCOLAR4_opacity
05206             but name was too long for some compilers */
05207             SUMA_RGBv_FGL_AR4op(\
05208             Overlays[i]->ColVec, glcolar, N_Node, Overlays[i]->GlobalOpacity, Overlays[i]->LocalOpacity, isColored);         
05209          } else if (SUMAg_CF->ColMixMode == SUMA_4AML) {
05210             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling SUMA_RGBv_FGL_AR4op2 ...\n", FuncName);
05211             SUMA_RGBv_FGL_AR4op2(\
05212             Overlays[i]->ColVec, glcolar, N_Node, Overlays[i]->GlobalOpacity, Overlays[i]->LocalOpacity, isColored); 
05213          }
05214       }
05215       
05216       if (!Full && Glob && Locl) {
05217          if (SUMAg_CF->ColMixMode == SUMA_ORIG_MIX_MODE) {
05218             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling SUMA_RGBv_PGL_AR4op ...\n", FuncName);
05219             /* This macro used to be called: SUMA_RGBmat_PartGlobLoc2_GLCOLAR4_opacity */
05220             SUMA_RGBv_PGL_AR4op(\
05221             Overlays[i]->ColVec, NodeDef, glcolar, N_NodeDef, isColored, Overlays[i]->GlobalOpacity, Overlays[i]->LocalOpacity,  N_Node);
05222           } else if (SUMAg_CF->ColMixMode == SUMA_4AML) {  
05223             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling SUMA_RGBv_PGL_AR4op2 ...\n", FuncName);
05224             SUMA_RGBv_PGL_AR4op2(\
05225             Overlays[i]->ColVec, NodeDef, glcolar, N_NodeDef, isColored, Overlays[i]->GlobalOpacity, Overlays[i]->LocalOpacity,  N_Node);
05226          }
05227       }
05228       
05229       if (Full && !Glob && Locl) {
05230          if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling  SUMA_RGBv_FnGL_AR4op...\n", FuncName);
05231          /* This macro used to be called: SUMA_RGBmat_FullNoGlobLoc2_GLCOLAR4_opacity */
05232          SUMA_RGBv_FnGL_AR4op(\
05233          Overlays[i]->ColVec, glcolar, N_Node, Overlays[i]->LocalOpacity, isColored);         
05234       }
05235       
05236       if (!Full && !Glob && Locl) {
05237          if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling SUMA_RGBv_PnGL_AR4op ...\n", FuncName);
05238          /* This macro used to be called: SUMA_RGBmat_PartNoGlobLoc2_GLCOLAR4_opacity*/
05239          SUMA_RGBv_PnGL_AR4op(\
05240          Overlays[i]->ColVec, NodeDef, glcolar, N_NodeDef, isColored, Overlays[i]->LocalOpacity, N_Node);
05241       }
05242       
05243       if (Full && !Glob && !Locl) {
05244          if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling SUMA_RGBv_FnGnL_AR4op ...\n", FuncName);
05245          /* This macro used to be called: SUMA_RGBmat_FullNoGlobNoLoc2_GLCOLAR4_opacity*/
05246          SUMA_RGBv_FnGnL_AR4op(\
05247          Overlays[i]->ColVec, glcolar, N_Node, isColored);         
05248       }
05249       
05250       if (!Full && !Glob && !Locl) {
05251          if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling SUMA_RGBv_PnGnL_AR4op ...\n", FuncName);  
05252          /* This macro used to be called: SUMA_RGBmat_PartNoGlobNoLoc2_GLCOLAR4_opacity */
05253          SUMA_RGBv_PnGnL_AR4op(\
05254          Overlays[i]->ColVec, NodeDef, glcolar, N_NodeDef, isColored, N_Node);
05255       }
05256       
05257       if (Full && Glob && !Locl) {
05258          if (SUMAg_CF->ColMixMode == SUMA_ORIG_MIX_MODE) {
05259             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling  SUMA_RGBv_FGnL_AR4op...\n", FuncName);
05260             /* This macro used to be called: SUMA_RGBmat_FullGlobNoLoc2_GLCOLAR4_opacity*/
05261             SUMA_RGBv_FGnL_AR4op(\
05262             Overlays[i]->ColVec, glcolar, N_Node, Overlays[i]->GlobalOpacity, isColored);
05263          } else if (SUMAg_CF->ColMixMode == SUMA_4AML){
05264             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling  SUMA_RGBv_FGnL_AR4op2...\n", FuncName);
05265             SUMA_RGBv_FGnL_AR4op2(\
05266             Overlays[i]->ColVec, glcolar, N_Node, Overlays[i]->GlobalOpacity, isColored);
05267          }
05268          
05269       }
05270        
05271       if (!Full && Glob && !Locl) {
05272          if (SUMAg_CF->ColMixMode == SUMA_ORIG_MIX_MODE) {
05273             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling  SUMA_RGBv_PGnL_AR4op...\n", FuncName);
05274             /* This macro used to be called: SUMA_RGBmat_PartGlobNoLoc2_GLCOLAR4_opacity*/
05275             SUMA_RGBv_PGnL_AR4op(\
05276             Overlays[i]->ColVec, NodeDef, glcolar, N_NodeDef, isColored, Overlays[i]->GlobalOpacity, N_Node);
05277          } else if (SUMAg_CF->ColMixMode == SUMA_4AML){
05278             if (LocalHead) fprintf (SUMA_STDOUT,"%s: Calling  SUMA_RGBv_PGnL_AR4op2...\n", FuncName);
05279             SUMA_RGBv_PGnL_AR4op2(\
05280             Overlays[i]->ColVec, NodeDef, glcolar, N_NodeDef, isColored, Overlays[i]->GlobalOpacity, N_Node);
05281          }
05282       }
05283          
05284    }
05285    
05286    if (FILL && Fill) { /* nothing to see here */
05287       if (LocalHead) fprintf (SUMA_STDOUT,"%s: Some nodes received no colors from any of the overplanes, filling them with background color ...\n", FuncName);
05288       SUMA_FillBlanks_GLCOLAR4(isColored, N_Node, SUMA_GRAY_NODE_COLOR, SUMA_GRAY_NODE_COLOR, SUMA_GRAY_NODE_COLOR, glcolar);
05289       SUMA_RETURN (YUP);
05290    }
05291    
05292    SUMA_RETURN (YUP);
05293 }

SUMA_Boolean SUMA_MovePlaneDown SUMA_SurfaceObject   SO,
char *    Name
 

Moves a plane up one order.

Definition at line 5843 of file SUMA_Color.c.

References DListElmt_::data, dlist_destroy(), dlist_head, dlist_ins_prev(), dlist_remove(), dlist_tail, SUMA_OVERLAYS::isBackGrnd, LocalHead, SUMA_SurfaceObject::N_Overlays, DListElmt_::next, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_SurfaceObject::Overlays, DListElmt_::prev, SUMA_Boolean, SUMA_ENTRY, SUMA_Fetch_OverlayPointer(), SUMA_free, SUMA_LH, SUMA_ListOrderToPlaneOrder(), SUMA_OverlaysToOrderedList(), SUMA_RETURN, and SUMA_S_Err.

Referenced by SUMA_ColPlane_NewOrder().

05844 {
05845    static char FuncName[]={"SUMA_MovePlaneDown"};
05846    SUMA_OVERLAYS *Overlay=NULL;
05847    SUMA_OVERLAY_LIST_DATUM *OvD=NULL;
05848    DList *list=NULL;
05849    DListElmt *Elm = NULL;
05850    int junk=0;
05851    SUMA_Boolean Found = NOPE, LocalHead = NOPE;
05852    
05853    SUMA_ENTRY; 
05854    
05855    /* search for the plane by name */
05856    SUMA_LH("Searching for plane");
05857    if (!(Overlay = SUMA_Fetch_OverlayPointer(SO->Overlays, SO->N_Overlays, Name, &junk))) {
05858       SUMA_S_Err("Plane does not exist in SO->Overlays. (identified by name)");
05859       SUMA_RETURN (NOPE);
05860    }
05861    
05862    /* get the list of planes */
05863    SUMA_LH("Creating list");
05864    if (Overlay->isBackGrnd) list = SUMA_OverlaysToOrderedList (SO, -1);
05865    else list = SUMA_OverlaysToOrderedList (SO, 1);
05866    if (!list) {
05867       SUMA_S_Err("NULL list");
05868       SUMA_RETURN (NOPE);
05869    }
05870    
05871    /* Now search through the list until you find Overlay */
05872    SUMA_LH("Searching for plane in list");
05873    Found = NOPE;
05874    Elm = NULL;
05875    do {
05876       if (!Elm) Elm = dlist_head(list);
05877       else Elm = Elm->next;
05878       OvD = (SUMA_OVERLAY_LIST_DATUM *) Elm->data;
05879       if (OvD->Overlay == Overlay) Found = YUP;
05880    }while (Elm != dlist_tail(list) && !Found);
05881    
05882    if (!Found) {
05883       SUMA_S_Err("Strange, real strange.");
05884       SUMA_RETURN(NOPE);
05885    }
05886    
05887    SUMA_LH("Found element, inserting at new position");
05888    if (Elm != dlist_head(list)) { /* not on bottom, can move down */
05889       /* add Elm's data  before of Elm->prev */
05890       dlist_ins_prev (list, Elm->prev, Elm->data);
05891       /* remove Elm BUT NOT ITS DATA STRUCTURE!*/
05892       dlist_remove (list, Elm, (void *)(&OvD));
05893    } else {
05894       SUMA_LH("Reached the bottom");
05895    }
05896    
05897    SUMA_LH("Compacting");
05898    /* now compact the order just for good measure */
05899    SUMA_ListOrderToPlaneOrder (list);
05900 
05901    
05902    SUMA_LH("Clean up");
05903    dlist_destroy(list); SUMA_free(list);
05904    SUMA_RETURN(YUP);   
05905 }

SUMA_Boolean SUMA_MovePlaneUp SUMA_SurfaceObject   SO,
char *    Name
 

Moves a plane up one order.

Definition at line 5776 of file SUMA_Color.c.

References DListElmt_::data, dlist_destroy(), dlist_head, dlist_ins_next(), dlist_remove(), dlist_tail, SUMA_OVERLAYS::isBackGrnd, LocalHead, SUMA_SurfaceObject::N_Overlays, DListElmt_::next, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_SurfaceObject::Overlays, SUMA_Boolean, SUMA_ENTRY, SUMA_Fetch_OverlayPointer(), SUMA_free, SUMA_LH, SUMA_ListOrderToPlaneOrder(), SUMA_OverlaysToOrderedList(), SUMA_RETURN, and SUMA_S_Err.

Referenced by SUMA_ColPlane_NewOrder().

05777 {
05778    static char FuncName[]={"SUMA_MovePlaneUp"};
05779    SUMA_OVERLAYS *Overlay=NULL;
05780    SUMA_OVERLAY_LIST_DATUM *OvD=NULL;
05781    DList *list=NULL;
05782    DListElmt *Elm = NULL;
05783    int junk=0;
05784    SUMA_Boolean Found = NOPE, LocalHead = NOPE;
05785    
05786    SUMA_ENTRY; 
05787    
05788    /* search for the plane by name */
05789    SUMA_LH("Searching for plane");
05790    if (!(Overlay = SUMA_Fetch_OverlayPointer(SO->Overlays, SO->N_Overlays, Name, &junk))) {
05791       SUMA_S_Err("Plane does not exist in SO->Overlays. (identified by name)");
05792       SUMA_RETURN (NOPE);
05793    }
05794    
05795    /* get the list of planes */
05796    SUMA_LH("Creating list");
05797    if (Overlay->isBackGrnd) list = SUMA_OverlaysToOrderedList (SO, -1);
05798    else list = SUMA_OverlaysToOrderedList (SO, 1);
05799    if (!list) {
05800       SUMA_S_Err("NULL list");
05801       SUMA_RETURN (NOPE);
05802    }
05803    
05804    /* Now search through the list until you find Overlay */
05805    SUMA_LH("Searching for plane in list");
05806    Found = NOPE;
05807    Elm = NULL;
05808    do {
05809       if (!Elm) Elm = dlist_head(list);
05810       else Elm = Elm->next;
05811       OvD = (SUMA_OVERLAY_LIST_DATUM *) Elm->data;
05812       if (OvD->Overlay == Overlay) Found = YUP;
05813    }while (Elm != dlist_tail(list) && !Found);
05814    
05815    if (!Found) {
05816       SUMA_S_Err("Strange, real strange.");
05817       SUMA_RETURN(NOPE);
05818    }
05819    
05820    SUMA_LH("Found element, inserting at new position");
05821    if (Elm != dlist_tail(list)) { /* not on top, can move up */
05822       /* add Elm's data  ahead of Elm->next */
05823       dlist_ins_next (list, Elm->next, Elm->data);
05824       /* remove Elm BUT NOT ITS DATA STRUCTURE!*/
05825       dlist_remove (list, Elm, (void *)(&OvD));
05826    } else {
05827       SUMA_LH("Reached the top");
05828    }
05829    
05830    SUMA_LH("Compacting");
05831    /* now compact the order just for good measure */
05832    SUMA_ListOrderToPlaneOrder (list);
05833 
05834    
05835    SUMA_LH("Clean up");
05836    dlist_destroy(list); SUMA_free(list);
05837    SUMA_RETURN(YUP);   
05838 }

SUMA_Boolean SUMA_NewSurfaceGeometry SUMA_SurfaceObject   SO
 

Function called when a surface's geometry is changed (currently due to a change in the CoordBias)

Definition at line 1899 of file SUMA_Color.c.

References SUMA_SurfaceObject::aMaxDims, SUMA_SurfaceObject::aMinDims, SUMA_SurfaceObject::Center, i, SUMA_SurfaceObject::idcode_str, SUMA_SurfaceViewer::isShaded, LocalHead, SUMA_SurfaceObject::MaxDims, SUMA_SurfaceObject::MinDims, SUMA_SurfaceViewer::N_DO, SUMA_SurfaceObject::N_Node, SUMA_SurfaceViewer::NewGeom, SUMA_SurfaceObject::NodeDim, SUMA_SurfaceObject::NodeList, SUMA_SurfaceViewer::RegisteredDO, SUMA_Boolean, SUMA_ENTRY, SUMA_findSO_inDOv(), SUMA_isSO_G(), SUMA_LH, SUMA_MAX_VEC, SUMA_MIN_MAX_SUM_VECMAT_COL, SUMA_MIN_VEC, SUMA_RETURN, SUMAg_N_DOv, SUMAg_N_SVv, SUMA_X::TOPLEVEL, and SUMA_SurfaceViewer::X.

Referenced by SUMA_GetOverlaysFromParent(), SUMA_RemoveSO_CoordBias(), SUMA_SetSO_CoordBias(), and SUMA_TransferSO_CoordBias().

01900 {
01901    static char FuncName[]={"SUMA_NewSurfaceGeometry"};
01902    int ii, i;
01903    SUMA_Boolean LocalHead = NOPE;
01904    
01905    SUMA_ENTRY;
01906    
01907    /* first recompute the bounding box of the surface */
01908    /* Calculate Min, Max, Mean */
01909    
01910    SUMA_MIN_MAX_SUM_VECMAT_COL (SO->NodeList, SO->N_Node, SO->NodeDim, SO->MinDims, SO->MaxDims, SO->Center);
01911      
01912    SO->Center[0] /= SO->N_Node;
01913    SO->Center[1] /= SO->N_Node;
01914    SO->Center[2] /= SO->N_Node;
01915 
01916    SUMA_MIN_VEC (SO->MinDims, 3, SO->aMinDims );
01917    SUMA_MAX_VEC (SO->MaxDims, 3, SO->aMaxDims);
01918    
01919    /* find out what viewers this surface is registered with and which viewers show it */
01920    for (ii=0; ii<SUMAg_N_SVv; ++ii) {
01921       if (!SUMAg_SVv[ii].isShaded && SUMAg_SVv[ii].X->TOPLEVEL) {
01922          for (i=0; i< SUMAg_SVv[ii].N_DO; ++i) {
01923             if (SUMA_isSO_G(SUMAg_DOv[SUMAg_SVv[ii].RegisteredDO[i]], SUMAg_SVv[ii].CurGroupName)) {
01924                /* is this surface the same as SO ? */
01925                if (SUMA_findSO_inDOv(SO->idcode_str, SUMAg_DOv, SUMAg_N_DOv) == SUMAg_SVv[ii].RegisteredDO[i]) {
01926                   /* This surface is visible in this viewer, mark that viewer  */
01927                   SUMA_LH("Marking Viewer ");
01928                   SUMAg_SVv[ii].NewGeom = YUP;
01929                }
01930             }
01931          }
01932       }
01933    }
01934    
01935    SUMA_RETURN(YUP);
01936 }

SUMA_Boolean SUMA_OKassign SUMA_DSET   dset,
SUMA_SurfaceObject   SO
 

determines if a Dset can be assigned to a surface object

Definition at line 6654 of file SUMA_Color.c.

References SUMA_DSET::dnel, LocalHead, SUMA_SurfaceObject::N_Node, SDSET_IDMDOM, SUMA_AddNodeIndexColumn(), SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_GetDsetColIndex(), SUMA_GetDsetColRange(), SUMA_isDsetRelated(), SUMA_LH, SUMA_NODE_INDEX, SUMA_RETURN, SUMA_SL_Err, SUMA_SLP_Err, NI_element::vec_filled, and NI_element::vec_len.

Referenced by SUMA_LoadDsetFile().

06655 {
06656    static char FuncName[]={"SUMA_OKassign"};
06657    float range[2];
06658    int loc[2], *iv=NULL, N_i, lnp = 0;
06659    char *np = NULL, stmp[201];
06660    SUMA_Boolean LocalHead = NOPE;
06661        
06662    SUMA_ENTRY;
06663    
06664    if (!dset) SUMA_RETURN(NOPE);
06665    if (!SO) SUMA_RETURN(NOPE);
06666    
06667    /* does dset have a mesh parent ? */
06668    np = SDSET_IDMDOM(dset); if (np) lnp = strlen(np); else lnp = 0; 
06669    if (np && lnp) { 
06670       SUMA_LH("Has IDMDOM");
06671       /* has parent, verify against SO*/
06672       if (SUMA_isDsetRelated(dset, SO)) { SUMA_LH("Is Related"); SUMA_RETURN(YUP); }
06673       else { SUMA_LH("Is NOT Related"); SUMA_RETURN(NOPE); }
06674    }
06675    
06676    SUMA_LH("Has no parent, trying adoption");
06677    /* has no parent, check if you can adopt it*/
06678    iv = SUMA_GetDsetColIndex (dset, SUMA_NODE_INDEX, &N_i);
06679    if (!iv) {
06680       SUMA_LH("No node index column");
06681       /* No node index. Make sure vec_len <= SO->N_Node */
06682       if (dset->dnel->vec_len <= SO->N_Node) { 
06683          SUMA_LH("Number of values per column\n"
06684                       "is less than the number \n"
06685                       "of nodes in the surface.\n");
06686          if (dset->dnel->vec_filled != SO->N_Node) {
06687             SUMA_LH("Need to attach a node index column, if possible");
06688             /* attempt to assign a node index column */
06689             if (!SUMA_AddNodeIndexColumn(dset, SO)) {
06690                 SUMA_LH(" Failed to add a node index column");
06691                 SUMA_RETURN(NOPE);
06692             } else {           
06693                SUMA_LH("Added Index Column");
06694                SUMA_RETURN(YUP);
06695             }
06696          }else {
06697             SUMA_LH( "Looks like a full list of values\n"
06698                      "Techincally, there's no need for explicit node column.\n"
06699                      "But at times, the data are not ordered by ascending node \n"
06700                      "index which causes trouble.\nSo now I add a node index column"
06701                      " always which would help point to the problem if it arises");
06702             /* Sept 21 04, call SUMA_AddNodeIndexColumn, it is good for you. Might add an unecessary index column when none exit but makes things clear*/
06703             if (!SUMA_AddNodeIndexColumn(dset, SO)) {
06704                 SUMA_LH(" Failed to add a node index column");
06705                 SUMA_RETURN(NOPE);
06706             }        
06707             SUMA_LH("Added Index Column");
06708             SUMA_RETURN(YUP);
06709          }
06710       } else {
06711          snprintf(stmp, 200*sizeof(char), 
06712                         "Number of values per column (%d)\n"
06713                         "is larger than the number \n"
06714                         "of nodes (%d) in the surface.", dset->dnel->vec_len, SO->N_Node);
06715          SUMA_SLP_Err(stmp);
06716          SUMA_RETURN(NOPE);
06717       }
06718    } else {
06719       SUMA_LH("Node index column found");
06720       if (N_i != 1) { SUMA_SL_Err("No support for multiple\nnode index columns"); SUMA_RETURN(NOPE); }
06721       /* there is a node index column, see if the range is OK */
06722       if (!SUMA_GetDsetColRange(dset, iv[0], range, loc)) {
06723          SUMA_SLP_Err("Unexpect error in SUMA_GetDsetColRange");
06724          SUMA_free(iv); iv = NULL;
06725          SUMA_RETURN(NOPE);
06726       }
06727       if (range[0] < 0 || range[1] > SO->N_Node) {
06728          SUMA_SLP_Err("Node index range outside\n"
06729                       "0 and SO->N_Node");
06730          SUMA_free(iv); iv = NULL;
06731          SUMA_RETURN(NOPE);
06732       }
06733       /* Now we're OK to return on a positive note */
06734       SUMA_RETURN(YUP);      
06735    } 
06736       
06737    SUMA_SL_Err("Should not get here");   
06738    SUMA_RETURN(NOPE);
06739 }

SUMA_Boolean SUMA_Overlays_2_GLCOLAR4 SUMA_SurfaceObject   SO,
SUMA_SurfaceViewer   SV,
GLfloat *    glcolar
 

function to turn color overlay planes into GL color array

--- usage prior to Fri Nov 7 15:58:57 EST 2003 --- ans = SUMA_Overlays_2_GLCOLAR4(Overlays, N_Overlays, glar_ColorList, N_Node, Back_Modfact, ShowBackground, ShowForeground);

Parameters:
Overlays  (SUMA_OVERLAYS **) a pointer to the vector of overlay planes structure pointers
N_Overlays  (int) number of overlay plane structures
glar_ColorList  (GLfloat *) pointer to vector (4*SO->N_Node long) that contains the node colors
N_Node  (int) total number of nodes in Surface NOT in color overlay plane
Back_Modfact  (float) Background brightness modulation factor typically SAFNIg_cSV->Back_Modfact
ShowBackground  (SUMA_Boolean) flag for showing/hiding background (brightness modulating) colors
ShowForeground  (SUMA_Boolean) flag for showing/hiding foreground colors \ret YUP/NOPE
See also:
SUMA_MixOverlays
--- current usage --- ans = SUMA_Overlays_2_GLCOLAR4(SO, SV, glar_ColorList)
Parameters:
SO  (SUMA_SurfaceObject *) surface structure with all the parameters listed in the old usage needed, and more
SV  (SUMA_SurfaceViewer *) surface viewer structure with all the parameters listed in the old usage needed, and more
glar_ColorList  (GLfloat *) pointer to vector (4*SO->N_Node long) that contains the node colors

Definition at line 4821 of file SUMA_Color.c.

References SUMA_SurfaceViewer::Back_Modfact, SUMA_X_SurfCont::curColPlane, SUMA_SurfaceObject::FN, SUMA_OVERLAYS::GlobalOpacity, i, SUMA_OVERLAYS::isBackGrnd, LocalHead, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::N_Overlays, SUMA_X_AllView::NumForeSmoothing, SUMA_SurfaceObject::Overlays, SUMA_OVERLAYS::PlaneOrder, SUMA_OVERLAYS::Show, SUMA_SurfaceViewer::ShowBackground, SUMA_X_SurfCont::ShowCurOnly, SUMA_SurfaceViewer::ShowForeground, SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_free, SUMA_GRAY_NODE_COLOR, SUMA_LH, SUMA_MAX_OVERLAYS, SUMA_MixOverlays(), SUMA_RETURN, SUMA_Show_ColorOverlayPlanes(), SUMA_SL_Err, SUMA_SmoothAttr_Neighb_Rec(), SUMA_z_dqsort(), SUMA_SurfaceObject::SurfCont, and SUMA_CommonFields::X.

Referenced by SUMA_input(), SUMA_MixColors(), and SUMA_SwitchState().

04822 {
04823    static char FuncName[]={"SUMA_Overlays_2_GLCOLAR4"};
04824    int ShowOverLays[SUMA_MAX_OVERLAYS], ShowOverLays_Back[SUMA_MAX_OVERLAYS]; 
04825    int ShowOverLays_sort[SUMA_MAX_OVERLAYS], ShowOverLays_Back_sort[SUMA_MAX_OVERLAYS], iloc[SUMA_MAX_OVERLAYS];
04826    int OverlayOrder_Back[SUMA_MAX_OVERLAYS], OverlayOrder[SUMA_MAX_OVERLAYS];
04827    int i, j, NshowOverlays, NshowOverlays_Back, *isort, i4, i4_0, i4_1, i4_2;
04828    SUMA_Boolean *isColored, *isColored_Fore, *isColored_Back;
04829    GLfloat *glcolar_Fore , *glcolar_Fore_tmp, *glcolar_Back;
04830    float avg_Back, avgfact;
04831    SUMA_OVERLAYS ** Overlays;
04832    int N_Overlays;  
04833    int N_Node; 
04834    float Back_Modfact;
04835    SUMA_Boolean ShowBackground; 
04836    SUMA_Boolean ShowForeground;
04837    SUMA_Boolean LocalHead = NOPE; /* local headline debugging messages */   
04838    
04839    SUMA_ENTRY;
04840 
04841    if (!SO || !SV || !glcolar) {
04842       SUMA_SL_Err("Null input to SUMA_Overlays_2_GLCOLAR4!");
04843       SUMA_RETURN(NOPE);
04844    }
04845    
04846    /* old variable names */
04847    Overlays = SO->Overlays;
04848    N_Overlays = SO->N_Overlays; 
04849    N_Node = SO->N_Node; 
04850    Back_Modfact = SV->Back_Modfact;
04851    ShowBackground = SV->ShowBackground; 
04852    ShowForeground = SV->ShowForeground;
04853    
04854    if (LocalHead)   { 
04855       fprintf (SUMA_STDOUT, "%s: Showing all overlay planes.\n", FuncName);
04856       SUMA_Show_ColorOverlayPlanes (Overlays, N_Overlays, 0); 
04857    } 
04858    
04859 
04860    /* get the indices into the color structure vector of overlays to be shown */
04861    NshowOverlays = 0;
04862    NshowOverlays_Back = 0;
04863    for (j=0; j < N_Overlays; ++j) {
04864       if (Overlays[j]->Show && Overlays[j]->GlobalOpacity != 0) {
04865          if (Overlays[j]->isBackGrnd) {
04866             ShowOverLays_Back[NshowOverlays_Back] = j; 
04867             OverlayOrder_Back[NshowOverlays_Back] = Overlays[j]->PlaneOrder;
04868             ++ NshowOverlays_Back;
04869          }else {
04870             if (SO->SurfCont->ShowCurOnly) {
04871                if (SO->SurfCont->curColPlane == Overlays[j]) {
04872                   SUMA_LH("Le ShowCurOnly in action");
04873                   ShowOverLays[NshowOverlays] = j; 
04874                   OverlayOrder[NshowOverlays] = Overlays[j]->PlaneOrder;
04875                   ++ NshowOverlays;
04876                }
04877             } else {
04878                ShowOverLays[NshowOverlays] = j; 
04879                OverlayOrder[NshowOverlays] = Overlays[j]->PlaneOrder;
04880                ++ NshowOverlays;
04881             }
04882          }
04883       }
04884    }
04885 
04886    if (LocalHead)   fprintf (SUMA_STDERR,"%s: Found %d Mix overlays and %d Mix-Brightmod overlays.\n", FuncName, NshowOverlays, NshowOverlays_Back);
04887    
04888    /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv allocate space ------------------------------------*/
04889    
04890    isColored = (SUMA_Boolean *) SUMA_calloc (N_Node, sizeof(SUMA_Boolean));/* allocate for flag indicating the a node is colored */
04891    if (!isColored) {
04892       fprintf (SUMA_STDERR,"Error %s: Failed to allocate for isColored.\n", FuncName);
04893       SUMA_RETURN (NOPE);
04894    }
04895    
04896    glcolar_Back = NULL;
04897    isColored_Back = NULL;
04898    if (ShowBackground) {
04899       if (NshowOverlays_Back) {
04900          glcolar_Back = (GLfloat *) SUMA_calloc (4*N_Node, sizeof(GLfloat));
04901          isColored_Back = (SUMA_Boolean *) SUMA_calloc (N_Node, sizeof(SUMA_Boolean));
04902 
04903          if (!isColored_Back || !glcolar_Back) {
04904             fprintf (SUMA_STDERR,"Error %s: Failed to allocate for isColored_Back || glcolar_Back.\n", FuncName);
04905             SUMA_RETURN (NOPE);
04906          }
04907       }
04908    }
04909    
04910    isColored_Fore = NULL;
04911    glcolar_Fore = NULL;
04912    if (ShowForeground) {
04913       if (NshowOverlays) {
04914          glcolar_Fore = (GLfloat *) SUMA_calloc (4*N_Node, sizeof(GLfloat));
04915          isColored_Fore = (SUMA_Boolean *) SUMA_calloc (N_Node, sizeof(SUMA_Boolean));
04916 
04917          if (!isColored_Fore || !glcolar_Fore) {
04918             fprintf (SUMA_STDERR,"Error %s: Failed to allocate for isColored_Fore || glcolar_Fore.\n", FuncName);
04919             SUMA_RETURN (NOPE);
04920          }
04921       }      
04922    }
04923    /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ allocate space ------------------------------------*/
04924    
04925    /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Background colors ------------------------------*/
04926    
04927    if (ShowBackground) {
04928       /* arrange Background color planes by plane order in preparation for mixing them */
04929          /* sort plane order */
04930          if (NshowOverlays_Back > 1) {
04931             isort = SUMA_z_dqsort (OverlayOrder_Back, NshowOverlays_Back );
04932             /* use sorting by plane order to reorder ShowOverlays */
04933             for (j=0; j < NshowOverlays_Back; ++j) {
04934                ShowOverLays_Back_sort[j] = ShowOverLays_Back[isort[j]];
04935             }
04936             /* done with isort, free it */
04937             SUMA_free(isort);
04938          } 
04939          if (NshowOverlays_Back == 1) {
04940                ShowOverLays_Back_sort[0] = ShowOverLays_Back[0];
04941          }
04942 
04943 
04944       /* mix the colors that will constitute background*/
04945       if (NshowOverlays_Back) {
04946          if (LocalHead)   fprintf (SUMA_STDERR,"%s: Mixing Background colors ...\n", FuncName);
04947 
04948          if (!SUMA_MixOverlays (Overlays, N_Overlays, ShowOverLays_Back_sort, NshowOverlays_Back, glcolar_Back, N_Node, isColored_Back, NOPE)) {
04949             fprintf (SUMA_STDERR,"Error %s: Failed in SUMA_MixOverlays.\n", FuncName);
04950             SUMA_RETURN (NOPE);
04951          }
04952       } else {
04953          ShowBackground = NOPE;
04954       } 
04955    } else {
04956       NshowOverlays_Back = 0;
04957    }
04958    /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  Background colors ------------------------------*/
04959    
04960    
04961    /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Foreground  colors ------------------------------*/
04962    if (ShowForeground) {
04963       /* arrange foreground color planes by plane order */
04964          /* sort plane order */
04965          if (NshowOverlays > 1) {
04966             isort = SUMA_z_dqsort (OverlayOrder, NshowOverlays );
04967             /* use sorting by plane order to reorder ShowOverlays */
04968             for (j=0; j < NshowOverlays; ++j) {
04969                ShowOverLays_sort[j] = ShowOverLays[isort[j]];
04970             }
04971             /* done with isort, free it */
04972             SUMA_free(isort);
04973          } 
04974          if (NshowOverlays  == 1) {
04975             ShowOverLays_sort[0] = ShowOverLays[0];   
04976          }
04977    
04978 
04979       /* Now mix the foreground colors */
04980       if (NshowOverlays) {
04981             if (LocalHead)   fprintf (SUMA_STDERR,"%s: Mixing Foreground colors ....\n", FuncName);
04982             if (!SUMA_MixOverlays (Overlays, N_Overlays, ShowOverLays_sort, NshowOverlays, glcolar_Fore, N_Node, isColored_Fore, NOPE)) {
04983                fprintf (SUMA_STDERR,"Error %s: Failed in SUMA_MixOverlays.\n", FuncName);
04984                SUMA_RETURN (NOPE);
04985             }
04986             if (SUMAg_CF->X->NumForeSmoothing > 0) { 
04987                glcolar_Fore_tmp = NULL;
04988                glcolar_Fore_tmp = SUMA_SmoothAttr_Neighb_Rec (glcolar_Fore, 4*SO->N_Node, NULL, SO->FN, 4, SUMAg_CF->X->NumForeSmoothing); 
04989                if (!glcolar_Fore_tmp) {
04990                   SUMA_SL_Err("Smoothing failed.\n");
04991                } else {
04992                   SUMA_free(glcolar_Fore); glcolar_Fore = glcolar_Fore_tmp; glcolar_Fore_tmp = NULL;
04993                }
04994             }
04995       } else {
04996          ShowForeground = NOPE;
04997       }
04998    } else {
04999       NshowOverlays = 0;
05000    }
05001    /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  Foreground colors ------------------------------*/
05002 
05003    /* time to modulate the mixed colors with the average brightness */
05004    if (NshowOverlays && NshowOverlays_Back) {
05005       if (LocalHead)   fprintf (SUMA_STDERR,"%s: Modulating Brightness of Foreground colors ...\n", FuncName);
05006 
05007       for (i=0; i < N_Node; ++i) {
05008          avgfact = Back_Modfact / 3.0;
05009          if (isColored_Fore[i] && isColored_Back[i]) { /* colors from both sides, adjust brightness */
05010             i4_0 = 4 * i; i4_1 = i4_0 + 1; i4_2 = i4_0 + 2; 
05011             if (!Back_Modfact) {
05012                glcolar[i4_0] = glcolar_Fore[i4_0];
05013                glcolar[i4_1] = glcolar_Fore[i4_1];
05014                glcolar[i4_2] = glcolar_Fore[i4_2];
05015             } else {
05016                avg_Back = (glcolar_Back[i4_0] + glcolar_Back[i4_1] + glcolar_Back[i4_2]) * avgfact ;   
05017                glcolar[i4_0] = avg_Back * glcolar_Fore[i4_0];
05018                glcolar[i4_1] = avg_Back * glcolar_Fore[i4_1];
05019                glcolar[i4_2] = avg_Back * glcolar_Fore[i4_2];
05020             }
05021                isColored[i] = YUP;
05022                continue;
05023          }
05024          if (isColored_Fore[i]) {
05025             i4 = 4 * i;
05026             glcolar[i4] = glcolar_Fore[i4]; ++i4;
05027             glcolar[i4] = glcolar_Fore[i4]; ++i4;
05028             glcolar[i4] = glcolar_Fore[i4]; ++i4;
05029             isColored[i] = YUP;
05030             continue;
05031          }
05032          if (isColored_Back[i]) {
05033             i4 = 4 * i;
05034             glcolar[i4] = glcolar_Back[i4]; ++i4;
05035             glcolar[i4] = glcolar_Back[i4]; ++i4;
05036             glcolar[i4] = glcolar_Back[i4]; ++i4;
05037             isColored[i] = YUP;
05038             continue;
05039          } else {
05040             /* has never been colored, put defaults */
05041             i4 = 4 * i;
05042             glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05043             glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05044             glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05045             isColored[i] = NOPE;
05046          }
05047       }
05048       
05049       if (LocalHead)   fprintf (SUMA_STDERR,"%s: Done Modulating Brightness of overlay colors.\n", FuncName);
05050    } 
05051    if (NshowOverlays && !NshowOverlays_Back) {
05052       if (LocalHead)   fprintf (SUMA_STDERR,"%s: Only Foreground colors.\n", FuncName);
05053          for (i=0; i < N_Node; ++i) {
05054             if (isColored_Fore[i]) {
05055                i4 = 4 * i;
05056                glcolar[i4] = glcolar_Fore[i4]; ++i4;
05057                glcolar[i4] = glcolar_Fore[i4]; ++i4;
05058                glcolar[i4] = glcolar_Fore[i4]; ++i4;
05059                isColored[i] = YUP;
05060                continue;
05061             } else {
05062                i4 = 4 * i;
05063                glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05064                glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05065                glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05066                isColored[i] = NOPE;
05067             }
05068          }
05069    }
05070    
05071    if (!NshowOverlays && NshowOverlays_Back) {
05072       if (LocalHead)   fprintf (SUMA_STDERR,"%s: Only Background colors.\n", FuncName);
05073          for (i=0; i < N_Node; ++i) {
05074             if (isColored_Back[i]) {
05075                i4 = 4 * i;
05076                glcolar[i4] = glcolar_Back[i4]; ++i4;
05077                glcolar[i4] = glcolar_Back[i4]; ++i4;
05078                glcolar[i4] = glcolar_Back[i4]; ++i4;
05079                isColored[i] = YUP;
05080                continue;
05081             } else {
05082                i4 = 4 * i;
05083                glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05084                glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05085                glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05086                isColored[i] = NOPE;
05087             }
05088          }
05089    }
05090    
05091    if (!(ShowBackground) && !ShowForeground) {
05092       for (i=0; i < N_Node; ++i) {
05093          i4 = 4 * i;
05094          glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05095          glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05096          glcolar[i4] = SUMA_GRAY_NODE_COLOR; ++i4;
05097       }
05098    }
05099    
05100    /* free this mess and get out */   
05101    if (isColored) SUMA_free(isColored);
05102    if (isColored_Back) SUMA_free(isColored_Back);
05103    if (glcolar_Back) SUMA_free(glcolar_Back);
05104    if (isColored_Fore) SUMA_free(isColored_Fore);
05105    if (glcolar_Fore) SUMA_free(glcolar_Fore);
05106    
05107    SUMA_RETURN (YUP);
05108 }

DList* SUMA_OverlaysToOrderedList SUMA_SurfaceObject   SO,
int    Opt
 

Create an ordered list of the colorplanes in Overlays the sorting of the list is done based on BackMod followed by the order The function makes sure colorplane orders span 0 to N_Overlays-1.

Parameters:
SO  (SUMA_SurfaceObject *)
Opt  (int) -1 for background plane list only 1 for foreground plane list only 0 for both background followed by foreground
Returns:
list (DList *) a doubly linked list of the ordered color planes. NULL is returned in case of error. to free this list when you no longer need it, do: dlist_destroy(list); SUMA_free(list);

Definition at line 5498 of file SUMA_Color.c.

References DListElmt_::data, dlist_head, dlist_init(), dlist_ins_next(), dlist_ins_prev(), dlist_next, dlist_tail, i, SUMA_OVERLAYS::isBackGrnd, LocalHead, SUMA_SurfaceObject::N_Overlays, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_SurfaceObject::Overlays, SUMA_OVERLAYS::PlaneOrder, DList_::size, SUMA_Boolean, SUMA_ENTRY, SUMA_FreeOverlayListDatum(), SUMA_LH, SUMA_ListOrderToPlaneOrder(), SUMA_malloc, and SUMA_RETURN.

Referenced by SUMA_AddNewPlane(), SUMA_AssembleColorPlaneList(), SUMA_MovePlaneDown(), SUMA_MovePlaneUp(), and SUMA_PlaneOrder_Info().

05499 {
05500    static char FuncName[]={"SUMA_OverlaysToOrderedList"}; 
05501    DList *listop = NULL;
05502    DListElmt *Elmop=NULL;
05503    SUMA_OVERLAY_LIST_DATUM *OvD = NULL, *oOvD = NULL;
05504    int i, Shift, ShftPlaneOrder, oShftPlaneOrder;
05505    SUMA_OVERLAYS *oPlane=NULL;
05506    SUMA_Boolean Found, LocalHead = NOPE;  
05507    
05508    SUMA_ENTRY; 
05509    
05510    listop = (DList *)SUMA_malloc(sizeof(DList));
05511    
05512    dlist_init(listop, SUMA_FreeOverlayListDatum);
05513    SUMA_LH("Considering loop");
05514    for (i=0; i < SO->N_Overlays; ++i) {
05515       SUMA_LH("In Loop");
05516          OvD = (SUMA_OVERLAY_LIST_DATUM *)SUMA_malloc(sizeof(SUMA_OVERLAY_LIST_DATUM));
05517          OvD->Overlay = SO->Overlays[i];
05518          if (!OvD->Overlay) {
05519             SUMA_LH("NULL Overlay");
05520          }
05521             SUMA_LH("Here");
05522          if (OvD->Overlay->isBackGrnd && Opt == 1) continue;   /* that was an unwanted background */
05523          if (!OvD->Overlay->isBackGrnd && Opt == -1) continue; /* that was an unwanted foreground */
05524          if (!listop->size) {
05525             SUMA_LH("Very first");
05526             dlist_ins_next(listop, dlist_tail(listop), (void*)OvD);
05527          }else { /* must sort first */
05528             Elmop = NULL;
05529             do {
05530                SUMA_LH("Searching");
05531                Found = NOPE;
05532                if (!Elmop) {
05533                   Elmop = dlist_head(listop);
05534                } else {
05535                   Elmop = dlist_next(Elmop);
05536                }
05537                
05538                oOvD = (SUMA_OVERLAY_LIST_DATUM *)Elmop->data;
05539                
05540                /* transform PlaneOrder so that is reflects the Background modulation */
05541                Shift = SO->N_Overlays;
05542                
05543                if (OvD->Overlay->isBackGrnd) ShftPlaneOrder = OvD->Overlay->PlaneOrder - Shift;
05544                else ShftPlaneOrder = OvD->Overlay->PlaneOrder;
05545                
05546                if (oOvD->Overlay->isBackGrnd) oShftPlaneOrder = oOvD->Overlay->PlaneOrder - Shift;
05547                else oShftPlaneOrder = oOvD->Overlay->PlaneOrder; 
05548                
05549                if (ShftPlaneOrder <= oShftPlaneOrder) {
05550                   SUMA_LH ("Ins Prev");
05551                   dlist_ins_prev(listop, Elmop, (void *)OvD);
05552                   Found = YUP;
05553                } else if (Elmop == dlist_tail(listop)) {
05554                   SUMA_LH ("Ins Next");
05555                   /* reached the end, append */
05556                   dlist_ins_next(listop, Elmop, (void *)OvD);
05557                   Found = YUP;
05558                }
05559             } while (!Found);
05560          }
05561    }
05562     
05563 
05564    /* Now the list is sorted  
05565    Go through the planes and make sure that the orders 
05566    span 0 to N_Overlays -1 */
05567    SUMA_LH("Changing list order to plane order");
05568    SUMA_ListOrderToPlaneOrder (listop);
05569    
05570    SUMA_RETURN(listop);
05571 }

float* SUMA_PercRange float *    V,
float *    Vsort,
int    N_V,
float *    PercRange,
float *    PercRangeVal,
int *    iPercRangeVal
 

A function to compute the percentile range.

Vsort = SUMA_PercRange (V, Vsort, N_V, PercRange, PercRangeVal, iPercRangeVal)

Parameters:
V  (float *) pointer to vector containing N_V values
Vsort  (float *) pointer to sorted version of V. NOTE: If you want the function to sort V for you then pass NULL here and expect the pointer to Vsort to be returned
N_V  (int) number of values in V
PercRange  (float *) 2x1 vector with percentile range desired (values between 0 and 100)
PercRangeVal  (float *) 2x1 vector with values in V corresponding the percentile range
iPercRangeVal  (int *) 2 x 1 vector containing indices into Vsort of PercRangeVal. i.e. PercRangeVal[0] = Vsort[iPercRangeVal[0]]; PercRangeVal[1] = Vsort[iPercRangeVal[1]]; pass NULL if you do not care for it. \ret Vsort, pointer to the sorted version of V. NULL in case of error. NOTE: Before a NULL is returned, Vsort is freed.
This function only allocates space for Vsort if a null is passed for Vsort in the function call

See also:
SUMA_dPercRange

Definition at line 4487 of file SUMA_Color.c.

References SUMA_calloc, SUMA_COPY_VEC, SUMA_ENTRY, SUMA_free, SUMA_RETURN, and SUMA_z_qsort().

Referenced by SUMA_input(), SUMA_NodeVal2irgba_nel(), and SUMA_SetConvexityPlaneDefaults().

04488 {
04489    static char FuncName[] = {"SUMA_PercRange"};
04490    int *isort, il, ih;
04491    
04492    SUMA_ENTRY;
04493 
04494    if (PercRange[0] < 0 || PercRange[0] > 100 || PercRange[1] < 0 || PercRange[1] > 100) {
04495       fprintf (SUMA_STDERR, "Error %s: Values in PercRange must be between 0 and 100.\nVsort will be freed.\n", FuncName);
04496       if (Vsort) SUMA_free(Vsort);
04497       SUMA_RETURN (NULL);
04498    }
04499     
04500    if (!Vsort) {
04501       /* need to create my own sorted version */
04502         Vsort = (float *)SUMA_calloc (N_V, sizeof(float));
04503       if (!Vsort) {
04504          fprintf (SUMA_STDERR, "Error %s: Failed to allocate for Vsort.\n", FuncName);
04505          SUMA_RETURN (NULL);
04506       }
04507       /* copy V to Vsort */
04508       SUMA_COPY_VEC (V, Vsort, N_V, float, float);
04509       
04510       /* sort Vsort */
04511       isort = SUMA_z_qsort (Vsort  , N_V ); SUMA_free(isort);
04512    } 
04513    
04514    /* choose the index for the lower range */
04515    il = (int)rint((N_V-1)*PercRange[0]/100.0);
04516    ih = (int)rint((N_V-1)*PercRange[1]/100.0);
04517    PercRangeVal[0] = Vsort[il];
04518    PercRangeVal[1] = Vsort[ih];
04519    if (iPercRangeVal) { 
04520       iPercRangeVal[0] = il; iPercRangeVal[1] = ih;
04521    }
04522    SUMA_RETURN (Vsort);
04523 }

char* SUMA_PlaneOrder_Info SUMA_SurfaceObject   SO
 

Shows the overlay plane order.

Definition at line 5723 of file SUMA_Color.c.

References DListElmt_::data, dlist_head, dlist_tail, SUMA_OVERLAYS::Label, SUMA_OVERLAYS::Name, DListElmt_::next, SUMA_OVERLAY_LIST_DATUM::Overlay, SUMA_OVERLAYS::PlaneOrder, SUMA_STRING::s, DList_::size, SUMA_ENTRY, SUMA_free, SUMA_OverlaysToOrderedList(), SUMA_RETURN, and SUMA_StringAppend().

Referenced by SUMA_Print_PlaneOrder().

05724 {
05725    static char FuncName[]={"SUMA_PlaneOrder_Info"};
05726    char stmp[1000], *s = NULL;
05727    SUMA_STRING *SS = NULL;
05728    DList *list=NULL;
05729    DListElmt *Elm=NULL;
05730    SUMA_OVERLAY_LIST_DATUM *OvD=NULL;
05731    
05732    SUMA_ENTRY;
05733 
05734    /* get the background and foreground lists */
05735    SS = SUMA_StringAppend (NULL, NULL);
05736       
05737    if (!(list = SUMA_OverlaysToOrderedList (SO, -1))) {
05738       SS = SUMA_StringAppend (SS,"NULL Background list\n");
05739    }else if (!list->size) {
05740       SS = SUMA_StringAppend (SS,"Empty Background list\n");
05741    } else {
05742       Elm=NULL;
05743       do {
05744          if (!Elm) Elm = dlist_head(list);
05745          else Elm = Elm->next;
05746          OvD = (SUMA_OVERLAY_LIST_DATUM *)Elm->data;
05747          sprintf (stmp,"BK: %s o%d (%s)\n", OvD->Overlay->Label, OvD->Overlay->PlaneOrder, OvD->Overlay->Name );
05748          SS = SUMA_StringAppend (SS,stmp);
05749       } while (Elm != dlist_tail(list));
05750    }
05751    
05752    if (!(list = SUMA_OverlaysToOrderedList (SO, 1))) {
05753       SS = SUMA_StringAppend (SS,"NULL Foreground list\n");
05754    }else if (!list->size) {
05755       SS = SUMA_StringAppend (SS,"Empty Foreground list\n");
05756    } else {
05757       Elm=NULL;
05758       do {
05759          if (!Elm) Elm = dlist_head(list);
05760          else Elm = Elm->next;
05761          OvD = (SUMA_OVERLAY_LIST_DATUM *)Elm->data;
05762          sprintf (stmp,"FG: %s o%d (%s)\n", OvD->Overlay->Label, OvD->Overlay->PlaneOrder, OvD->Overlay->Name );
05763          SS = SUMA_StringAppend (SS,stmp);
05764       } while (Elm != dlist_tail(list));
05765    }
05766    
05767    s = SS->s;
05768    SUMA_free(SS);
05769    
05770    SUMA_RETURN (s);
05771 }

void SUMA_Print_PlaneOrder SUMA_SurfaceObject   SO,
FILE *    Out
 

Definition at line 5699 of file SUMA_Color.c.

References SUMA_ENTRY, SUMA_free, SUMA_PlaneOrder_Info(), and SUMA_RETURNe.

Referenced by SUMA_ColPlane_NewOrder().

05700 {   
05701    static char FuncName[]={"SUMA_Print_PlaneOrder"};
05702    char *s;
05703    
05704    SUMA_ENTRY;
05705 
05706    if (Out == NULL) Out = stdout;
05707       
05708    s =  SUMA_PlaneOrder_Info(SO);
05709    
05710    if (s) {
05711       fprintf (Out, "%s", s);
05712       SUMA_free(s);
05713    }else {
05714       fprintf (SUMA_STDERR, "Error %s: Failed in SUMA_PlaneOrder_Info.\n", FuncName);
05715    }   
05716    
05717    SUMA_RETURNe;
05718 }   

SUMA_COLOR_MAP* SUMA_Read_Color_Map_1D char *    Name
 

function that reads in a 1D format color map file 1D format contains 3 or 4 columns: 3 columns: R G B 4 columns: R G B frac R G B are float values between 0 and 1.0 specifying the R G B colors frac is the fraction of the color map assigned to each color. These are the same numbers shown to the right of the colormap in AFNI Sept 22 04: you can specify integer values between 0 and 255 for the RGB values if you wish

The colormap files are specified in the order adopted in AFNI's palette files The last row in the file is the first color (bottom color) in the map. If you specify frac then the lowest fraction must be at the bottom row

Definition at line 1045 of file SUMA_Color.c.

References SUMA_COLOR_MAP::cname, far, SUMA_COLOR_MAP::frac, i, LocalHead, SUMA_COLOR_MAP::M, MRI_FLOAT_PTR, mri_free(), mri_read_1D(), SUMA_COLOR_MAP::N_Col, SUMA_COLOR_MAP::Name, MRI_IMAGE::nx, MRI_IMAGE::ny, SUMA_COLOR_MAP::Sgn, SUMA_COLOR_MAP::SO, SUMA_allocate2D(), SUMA_Boolean, SUMA_calloc, SUMA_disp_mat(), SUMA_ENTRY, SUMA_Free_ColorMap(), SUMA_malloc, SUMA_RETURN, and SUMA_S_Err.

Referenced by SUMA_LoadCmapFile().

01046 {
01047    static char FuncName[]={"SUMA_Read_Color_Map_1D"};
01048    MRI_IMAGE *im = NULL;
01049    float *far=NULL;
01050    float ColSum;
01051    int i=0;
01052    SUMA_COLOR_MAP* SM = NULL;
01053    SUMA_Boolean LocalHead = NOPE;
01054    
01055    SUMA_ENTRY;
01056 
01057    if (!Name) {
01058       SUMA_S_Err("NULL file name");
01059       SUMA_RETURN(SM);
01060    }
01061    
01062    /* read the colormap 1D file */
01063    im = mri_read_1D (Name);
01064    if (!im) {
01065       SUMA_S_Err("Failed to read file");
01066       SUMA_RETURN(NULL);
01067    }
01068 
01069    /* check for sizes */
01070    if (im->ny != 3 && im->ny != 4) {
01071       SUMA_S_Err("File must contain 3 or 4 columns only");
01072       SUMA_RETURN(NULL);
01073       
01074    }
01075    
01076    
01077    /* allocate for SM */
01078    SM = (SUMA_COLOR_MAP*) SUMA_malloc(sizeof(SUMA_COLOR_MAP));
01079    SM->SO = NULL; 
01080    SM->cname = NULL;
01081    SM->N_Col = im->nx;
01082    SM->Name = (char *)SUMA_malloc(sizeof(char)*(strlen(Name)+1));
01083    sprintf(SM->Name, "%s", Name);
01084    if (im->ny == 4) {
01085       SM->frac = (float*) SUMA_calloc(im->nx, sizeof(float));
01086    } else {
01087       SM->frac = NULL;
01088    }
01089    
01090    SM->M = (float**)SUMA_allocate2D (SM->N_Col, 3, sizeof(float));
01091    
01092    
01093    far = MRI_FLOAT_PTR(im);
01094    
01095    ColSum = 0;
01096    if (im->ny == 4) {
01097       SM->Sgn = 1;
01098       for (i=0; i < im->nx; ++i) {
01099          SM->M[SM->N_Col - i - 1][0] = far[i]; ColSum += far[i];
01100          SM->M[SM->N_Col - i - 1][1] = far[i+im->nx]; ColSum += far[i+im->nx];
01101          SM->M[SM->N_Col - i - 1][2] = far[i+2*im->nx]; ColSum += far[i+2*im->nx];
01102          SM->frac[SM->N_Col - i - 1] = far[i+3*im->nx];
01103          if (SM->frac[SM->N_Col - i - 1] < 0.0) SM->Sgn = -1;
01104       }
01105    } else {
01106       SM->Sgn = 0;
01107       for (i=0; i < im->nx; ++i) {
01108          SM->M[SM->N_Col - i - 1][0] = far[i]; ColSum += far[i];
01109          SM->M[SM->N_Col - i - 1][1] = far[i+im->nx]; ColSum += far[i+im->nx];
01110          SM->M[SM->N_Col - i - 1][2] = far[i+2*im->nx]; ColSum += far[i+2*im->nx];
01111       }
01112    }
01113    
01114    ColSum = ColSum / (3.0 *  SM->N_Col);
01115    if (ColSum > 1) {
01116       /* looks like colormap values are between 0 and 255 */
01117       for (i=0; i < SM->N_Col; ++i) {
01118          SM->M[i][0] /= 255.0; SM->M[i][1] /= 255.0;  SM->M[i][2] /= 255.0;
01119       }
01120    }
01121    
01122    /* check on craziness in frac */
01123    if (SM->frac && SM->N_Col > 1) {
01124       for (i=0; i < im->nx-1; ++i) {
01125          if (SM->frac[i] > SM->frac[i+1]) {
01126             SUMA_S_Err("Fractions must be specified in monotonic\n descending order from the top to the bottom of the column");
01127             SUMA_Free_ColorMap (SM); mri_free(im);
01128             SUMA_RETURN(NULL);
01129          }
01130       }
01131    }
01132    
01133    mri_free(im); im = NULL; 
01134    
01135    if (LocalHead) {
01136       fprintf (SUMA_STDERR,"%s: Colormap read:\n", FuncName);
01137       if (SM->frac) {
01138          for (i=0; i < SM->N_Col; ++i) {
01139             fprintf (SUMA_STDOUT,"%f\t%f\t%f\t%f\n", SM->M[i][0], SM->M[i][1], SM->M[i][2], SM->frac[i]);
01140          }
01141       } else SUMA_disp_mat (SM->M, SM->N_Col, 3, 1);
01142    }
01143    
01144    
01145    SUMA_RETURN (SM);
01146 }

void SUMA_RefreshDsetList SUMA_SurfaceObject   SO
 

refreshes a colorplane list. A combo of SUMA_AssembleColorPlaneList and SUMA_CreateScrolledList.

Definition at line 6332 of file SUMA_Color.c.

References SUMA_LIST_WIDGET::ALS, SUMA_ASSEMBLE_LIST_STRUCT::clist, i, LocalHead, SUMA_ASSEMBLE_LIST_STRUCT::N_clist, SUMA_AssembleColorPlaneList(), SUMA_Boolean, SUMA_CreateScrolledList(), SUMA_ENTRY, SUMA_FreeAssembleListStruct(), SUMA_RETURNe, SUMA_S_Err, SUMA_SL_Err, SUMA_SLP_Err, SUMA_SLP_Note, SUMA_SurfaceObject::SurfCont, and SUMA_X_SurfCont::SwitchDsetlst.

Referenced by SUMA_cb_SurfCont_SwitchColPlane(), SUMA_ColPlane_NewOrder(), SUMA_LoadColorPlaneFile(), and SUMA_LoadDsetFile().

06333 {
06334    static char FuncName[]={"SUMA_RefreshDsetList"};
06335    SUMA_LIST_WIDGET *LW = NULL;
06336    SUMA_Boolean LocalHead = NOPE;
06337    
06338    SUMA_ENTRY;
06339    
06340    LW = SO->SurfCont->SwitchDsetlst;
06341    
06342    if (!LW) SUMA_RETURNe;
06343    
06344    if (LW->ALS) {
06345       /* free that old hag */
06346       if (LocalHead) SUMA_S_Err("Freeing the hag.");
06347       LW->ALS = SUMA_FreeAssembleListStruct(LW->ALS);
06348    }
06349    
06350    
06351    /* assemble the ColorPlane list */
06352    LW->ALS = SUMA_AssembleColorPlaneList (SO);
06353   
06354    if (!LW->ALS) {
06355       SUMA_SLP_Err("Error assembling list.");
06356       SUMA_RETURNe;
06357    }
06358    
06359    if (LW->ALS->N_clist < 0) {
06360       SUMA_SL_Err("Failed in SUMA_AssembleColorPlaneList");
06361       SUMA_RETURNe;
06362    }
06363    
06364    if (!LW->ALS->N_clist) {
06365       SUMA_SLP_Note ("No Color planes to choose from.");
06366       SUMA_RETURNe;
06367    }
06368    
06369    if (LocalHead) {
06370       int i;
06371       for (i=0; i < LW->ALS->N_clist; ++i) fprintf (SUMA_STDERR,"%s: %s\n", FuncName, LW->ALS->clist[i]);
06372    }
06373    SUMA_CreateScrolledList ( LW->ALS->clist, LW->ALS->N_clist, NOPE,
06374                              LW);
06375    
06376    SUMA_RETURNe;
06377 }  

SUMA_Boolean SUMA_ReleaseOverlay SUMA_OVERLAYS   Overlays,
SUMA_INODE   Overlays_Inode
 

releases an overlay pointer (decrement its inode count and free it if necessary)

Definition at line 4698 of file SUMA_Color.c.

References LocalHead, SUMA_OVERLAYS::Name, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_FreeOverlayPointer(), SUMA_ReleaseLink(), and SUMA_RETURN.

04699 {
04700    static char FuncName[]={"SUMA_ReleaseOverlay"};
04701    SUMA_Boolean LocalHead = NOPE;
04702 
04703    SUMA_ENTRY;
04704    
04705    if (Overlays_Inode || Overlays) { /* there should be no case where only one of two is null but if such a case existed, you'll get notified below. */
04706       if (SUMA_ReleaseLink(Overlays_Inode)) { 
04707          /* some links are left, do not free memory */
04708       } else {
04709          if (LocalHead) fprintf (SUMA_STDERR,"%s: Overlay plane %s is free of links, freeing allocated memory ...\n", FuncName, Overlays->Name);
04710          if (Overlays) SUMA_FreeOverlayPointer (Overlays);
04711          if (Overlays_Inode) SUMA_free(Overlays_Inode); 
04712       }
04713    }   
04714    SUMA_RETURN(YUP);
04715 }

SUMA_Boolean SUMA_RemoveCoordBias SUMA_OVERLAYS   ovr
 

Definition at line 2059 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::BiasVect, SUMA_SCALE_TO_MAP_OPT::DoBias, i, SUMA_SurfaceObject::Label, LocalHead, SUMA_DO::OP, SUMA_OVERLAYS::OptScl, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_isOverlayOfSO(), SUMA_isSO(), SUMA_LH, SUMA_RemoveSO_CoordBias(), SUMA_RETURN, SUMAg_N_DOv, and SW_CoordBias_None.

Referenced by SUMA_cb_SetCoordBias(), and SUMA_ScaleToMap_Interactive().

02060 {
02061    static char FuncName[]={"SUMA_RemoveCoordBias"};
02062    int i, i3, iso;
02063    SUMA_SurfaceObject *SO=NULL;
02064    SUMA_Boolean LocalHead = NOPE;
02065    SUMA_ENTRY;
02066    
02067    if (!ovr) SUMA_RETURN(YUP);
02068    if (ovr->OptScl->BiasVect) { /* something to be removed */
02069       for (iso=0; iso<SUMAg_N_DOv; ++iso) {
02070          if (SUMA_isSO(SUMAg_DOv[iso])) {
02071             SO = (SUMA_SurfaceObject *)SUMAg_DOv[iso].OP;
02072             if (SUMA_isOverlayOfSO(SO, ovr)) {
02073                SUMA_LH(SO->Label);
02074                SUMA_RemoveSO_CoordBias(SO, ovr);     
02075             } 
02076          }
02077       }
02078       /* Now free BiasVect */
02079       SUMA_free(ovr->OptScl->BiasVect); 
02080    }
02081    ovr->OptScl->BiasVect = NULL;
02082    ovr->OptScl->DoBias = SW_CoordBias_None;
02083 
02084    SUMA_RETURN(YUP);
02085 } 

SUMA_Boolean SUMA_RemoveSO_CoordBias SUMA_SurfaceObject   SO,
SUMA_OVERLAYS   ovr
 

Definition at line 1710 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::BiasVect, SUMA_SCALE_TO_MAP_OPT::DoBias, i, SUMA_OVERLAYS::N_NodeDef, SUMA_OVERLAYS::NodeDef, SUMA_SurfaceObject::NodeList, SUMA_SurfaceObject::NodeNormList, SUMA_OVERLAYS::OptScl, SUMA_Boolean, SUMA_ENTRY, SUMA_NewSurfaceGeometry(), SUMA_RETURN, SUMA_SL_Err, SW_CoordBias_N, SW_CoordBias_X, SW_CoordBias_Y, and SW_CoordBias_Z.

Referenced by SUMA_RemoveCoordBias().

01711 {
01712    static char FuncName[]={"SUMA_RemoveSO_CoordBias"};
01713    int i, i3;
01714       
01715    SUMA_ENTRY;
01716    
01717    if (ovr->OptScl->BiasVect) { /* something to be removed */
01718       switch (ovr->OptScl->DoBias) {
01719          case SW_CoordBias_X:
01720             /* Remove X bias */
01721             for (i=0; i < ovr->N_NodeDef; ++i) {
01722                i3 = 3*ovr->NodeDef[i];
01723                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i];
01724             }
01725             break;
01726          case SW_CoordBias_Y:
01727             /* Remove Y bias */
01728             for (i=0; i < ovr->N_NodeDef; ++i) {
01729                i3 = 3*ovr->NodeDef[i]+1;
01730                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i];
01731             }
01732             break;
01733          case SW_CoordBias_Z:
01734             /* Remove Z bias */
01735             for (i=0; i < ovr->N_NodeDef; ++i) {
01736                i3 = 3*ovr->NodeDef[i]+2;
01737                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i];
01738             }
01739             break;
01740          case SW_CoordBias_N:
01741             /* Remove Normal bias */
01742             for (i=0; i < ovr->N_NodeDef; ++i) {
01743                i3 = 3*ovr->NodeDef[i];
01744                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3]; ++i3; 
01745                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3]; ++i3; 
01746                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3];  
01747             }
01748             break;
01749          default:
01750             SUMA_SL_Err("This should not be");
01751             SUMA_RETURN(NOPE);
01752       }
01753    } else {
01754       SUMA_SL_Err("DO not call me with no bias!");
01755       SUMA_RETURN(NOPE);
01756    }
01757 
01758    /* Update surface geometry properties */
01759    SUMA_NewSurfaceGeometry(SO);
01760 
01761    SUMA_RETURN(YUP);
01762 }

SUMA_Boolean SUMA_ScaleToMap float *    V,
int    N_V,
float    Vmin,
float    Vmax,
SUMA_COLOR_MAP   ColMap,
SUMA_SCALE_TO_MAP_OPT   Opt,
SUMA_COLOR_SCALED_VECT   SV
 

This function maps the values in a vector to colors on a color map Res = SUMA_ScaleToMap (V, N_V, Vmin, Vmax, ColMap, Opt, SV);

Parameters:
V  (float *) N_V x1 vector containing the values to be colorized by the map in ColMap.
N_V  (int) number of elements in V
Vmin  (float) minimum value in V
Vmax  (float) maximum value in V
ColMap  (SUMA_COLOR_MAP *) pointer to the color map
Opt  (SUMA_SCALE_TO_MAP_OPT *) is a structure containing the options for SUMA_ScaleToMap see help on SUMA_SCALE_TO_MAP_OPT for info on various options
SV  (SUMA_COLOR_SCALED_VECT *) is a pre-allocated structure that will contain the color mapped version of V. See the definition of SUMA_COLOR_SCALED_VECT for more info. \ret Res (SUMA_Boolean) good/bad
See also:
SUMA_Create_ColorScaledVect and SUMA_Free_ColorScaledVect , SUMA_ScaleToMapOptInit , SUMA_MakeColorMap
NOTES: +The brightness factor Opt->BrightFact is applied to the colormap in ColMap and the MaskColor in Opt +How Clipping is done: if (V[i] < Clip[0]) V[i] = Clip[0]; if (V[i] > Clip[1]) V[i] = Clip[1]; +Values in Mask Range are applied BEFORE the clipping is done IF (Mask[0] <= V[i] <= Mask[1]) V[i] is masked

Definition at line 2624 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::ApplyClip, SUMA_SCALE_TO_MAP_OPT::ApplyMask, SUMA_COLOR_SCALED_VECT::BiasCoordVec, SUMA_SCALE_TO_MAP_OPT::BrightFact, SUMA_SCALE_TO_MAP_OPT::CoordBiasRange, SUMA_COLOR_SCALED_VECT::cV, SUMA_SCALE_TO_MAP_OPT::DoBias, SUMA_COLOR_MAP::frac, i, i1, SUMA_SCALE_TO_MAP_OPT::interpmode, SUMA_SCALE_TO_MAP_OPT::IntRange, SUMA_COLOR_SCALED_VECT::isMasked, LocalHead, SUMA_COLOR_MAP::M, SUMA_SCALE_TO_MAP_OPT::MaskColor, SUMA_SCALE_TO_MAP_OPT::MaskRange, SUMA_SCALE_TO_MAP_OPT::MaskZero, SUMA_COLOR_MAP::N_Col, r, SUMA_COLOR_MAP::Sgn, SUMA_allocate2D(), SUMA_Boolean, SUMA_calloc, SUMA_DIRECT, SUMA_ENTRY, SUMA_free2D(), SUMA_Free_ColorMap(), SUMA_INTERP, SUMA_LH, SUMA_Linearize_Color_Map(), SUMA_NO_INTERP, SUMA_RETURN, SUMA_S_Warn, SUMA_SL_Crit, SUMA_SL_Err, SW_CoordBias_N, SW_CoordBias_X, SW_CoordBias_Y, and SW_CoordBias_Z.

Referenced by main(), SUMA_input(), SUMA_NodeVal2irgba_nel(), SUMA_ScaleToMap_Interactive(), and SUMA_SphereQuality().

02629 {
02630    static char FuncName[]={"SUMA_ScaleToMap"};
02631    int i,j, i0, i1, mxColindex, i3=0;
02632    float MinCol, MaxCol, Vrange, Vscl, r, **Mbuf= NULL;
02633    SUMA_Boolean NewMap = NOPE;
02634    SUMA_Boolean LocalHead = NOPE;
02635    
02636    SUMA_ENTRY;
02637 
02638    if (!ColMap) {
02639       SUMA_SL_Err("NULL ColMap");
02640       SUMA_RETURN(NOPE);
02641    }
02642    if (!Opt) {
02643       SUMA_SL_Err("NULL Opt");
02644       SUMA_RETURN(NOPE);
02645    }
02646    if (!SV) {
02647       SUMA_SL_Err("NULL SV");
02648       SUMA_RETURN(NOPE);
02649    }
02650    if (!V) {
02651       SUMA_SL_Err("NULL V");
02652       SUMA_RETURN(NOPE);
02653    }
02654    
02655    /* No negative colormaps here */
02656    if (ColMap->Sgn < 0) {
02657       /* proceed, in SUMA options were given to the user to make the range symmetric about 0.
02658       They can shoot themselves in the foot if they want to */
02659       SUMA_LH("Colormap is split into positive and negative.\n Make sure your range is from -a to + a to have the mapping resemble AFNI's");
02660    }
02661    
02662    /* find the values to be masked out */
02663    if (Opt->ApplyMask){
02664       SUMA_LH("Applying Mask");
02665       if (Opt->MaskZero) {
02666          /* mask zeros and values in range */
02667          for (i=0; i < N_V; ++i) {
02668             if (!V[i] || (V[i] >= Opt->MaskRange[0] && V[i] <= Opt->MaskRange[1]))  SV->isMasked[i] = YUP;
02669          }
02670       } else {
02671          /* don't mask zeros, just range */
02672          for (i=0; i < N_V; ++i) {
02673             if (V[i] >= Opt->MaskRange[0] && V[i] <= Opt->MaskRange[1])  SV->isMasked[i] = YUP;
02674          }
02675       }
02676    }else {
02677       if (Opt->MaskZero) {
02678          SUMA_LH("Masking Zeros");
02679         /* mask zeros */
02680          for (i=0; i < N_V; ++i) {
02681             if (!V[i]) SV->isMasked[i] = YUP;
02682          }
02683       }
02684    }
02685    
02686    /* go through and clip values in V to those specified in the range */
02687    if (Opt->ApplyClip) {
02688       SUMA_LH( "Applying Clip \n"
02689                "(This one's not used in\n"
02690                " interactive mode anymore \n"
02691                " because clipping is handled \n"
02692                " in the colormapping part)");
02693       for (i=0; i < N_V; ++i) {
02694          if (!SV->isMasked[i]) { /* don't waist time on masked stuff */
02695             if (V[i] > Opt->IntRange[0]) { 
02696                /* that's cool */
02697             } else {
02698                V[i] = Opt->IntRange[0];
02699             }
02700 
02701             if (V[i] < Opt->IntRange[1]) { 
02702                /* that's cool */
02703             } else {
02704                V[i] = Opt->IntRange[1];
02705             }
02706          } 
02707       }
02708       Vmin = Opt->IntRange[0];
02709       Vmax = Opt->IntRange[1];
02710    }
02711    
02712    /* Add any coord bias ? */
02713    if (Opt->DoBias == SW_CoordBias_X || Opt->DoBias == SW_CoordBias_Y || Opt->DoBias == SW_CoordBias_Z || Opt->DoBias == SW_CoordBias_N) {
02714       SUMA_LH("Coord Bias requested");
02715       if (!SV->BiasCoordVec) {
02716          SUMA_LH("Allocating for BiasCoordVec");
02717          SV->BiasCoordVec = (float *)SUMA_calloc(N_V, sizeof(float));
02718          if (!SV->BiasCoordVec) { SUMA_SL_Crit("Failed to allocate"); SUMA_RETURN(NOPE); }
02719       }else {
02720          SUMA_SL_Err("Do not expect this not to be null here ... ");
02721          SUMA_RETURN(NOPE);
02722       }
02723    } else {
02724       SUMA_LH("No Coord Bias requested");
02725       if (SV->BiasCoordVec) { 
02726          SUMA_SL_Err("Do NOT expect this not to be null here ... ");
02727          SUMA_RETURN(NOPE);
02728       }
02729    }
02730    
02731    /* is the colormap non-linear ? */
02732    if (ColMap->frac) {
02733       if (Opt->interpmode == SUMA_NO_INTERP || Opt->interpmode == SUMA_INTERP) {
02734          /* linearize color map */
02735          SUMA_LH("Linearizing colormap ...");
02736          NewMap = YUP;
02737          if (ColMap->frac[0] > 0 && ColMap->Sgn == -1) {
02738             SUMA_S_Warn ("Color map fractions are positive with Sgn flag = -1");
02739          }
02740          if (ColMap->frac[0] < 0 && ColMap->Sgn == 1) {
02741             SUMA_S_Warn ("Color map fractions are negative with Sgn flag = 1");
02742          }
02743          ColMap = SUMA_Linearize_Color_Map (ColMap, -1);
02744       } else {
02745          if (Opt->interpmode != SUMA_DIRECT) {
02746             SUMA_SL_Err("Not expected interpmode.");
02747             /* Do nothing to the colormap, direct mapping mode in gear */
02748             NewMap = NOPE;
02749          }
02750       }
02751    }else {
02752       SUMA_LH("NO Linearizing of colormap deemed necessary...");
02753       NewMap = NOPE;
02754    }
02755    
02756    /* if brightness factor is given, apply it to color map and mask color */
02757    Mbuf = NULL;
02758    if (Opt->BrightFact <= 0 || Opt->BrightFact > 1) {
02759       fprintf (SUMA_STDERR,"Error %s: Opt->BrightFact must be between ]0 1]\n", FuncName);
02760       SUMA_RETURN (NOPE);
02761    }else {
02762       if (Opt->BrightFact != 1) {
02763          SUMA_LH("Modulating brightness of map");
02764          Mbuf = ColMap->M; /* save pointer */
02765          ColMap->M = (float **)SUMA_allocate2D(ColMap->N_Col, 3, sizeof(float));
02766          for (i=0; i < ColMap->N_Col; ++i) {
02767             ColMap->M[i][0] = Mbuf[i][0] * Opt->BrightFact;
02768             ColMap->M[i][1] = Mbuf[i][1] * Opt->BrightFact;
02769             ColMap->M[i][2] = Mbuf[i][2] * Opt->BrightFact;
02770          }
02771          /* now for the mask color */
02772          Opt->MaskColor[0] *= Opt->BrightFact;
02773          Opt->MaskColor[1] *= Opt->BrightFact;
02774          Opt->MaskColor[2] *= Opt->BrightFact;
02775       }
02776    }
02777    
02778    
02779    if (Opt->interpmode != SUMA_DIRECT && Opt->interpmode != SUMA_NO_INTERP && Opt->interpmode != SUMA_INTERP) {
02780       fprintf (SUMA_STDERR,"Error %s: Opt->interpmode is incorrectly specifed (%d).\n", FuncName, Opt->interpmode);
02781       SUMA_RETURN(NOPE);
02782    }
02783    
02784    if (Opt->interpmode == SUMA_NO_INTERP || Opt->interpmode == SUMA_INTERP) {
02785       /* Now go through values and interpolate onto index of colormap */
02786       MinCol = 0.0; MaxCol = (float)ColMap->N_Col; 
02787       Vrange = Vmax - Vmin; 
02788       if (Vrange < 0) {
02789          fprintf (SUMA_STDERR,"Error %s: Vmax < Vmin.\n", FuncName);
02790          SUMA_RETURN (NOPE);
02791       }
02792 
02793       if (Vrange > 0) {
02794          mxColindex = ColMap->N_Col -1; 
02795          if (Opt->interpmode == SUMA_NO_INTERP) { /* no interpolation between colours */
02796             SUMA_LH("No Interp Mode");
02797             for (i=0; i < N_V; ++i) {
02798                i3 = 3*i;
02799                if (!SV->isMasked[i]) {
02800                   Vscl = (V[i] - Vmin) / Vrange * ColMap->N_Col; /* used mxColindex instead of N_Col (wrong!) prior to Oct 22, 03 */
02801                   if (Vscl < 0) Vscl = 0; if (Vscl > ColMap->N_Col) Vscl = ColMap->N_Col; /* This happens when your Min--Max are within the boundaries of the data's (V[i]) min to max */
02802                   i0 = (int)(Vscl); 
02803                   if (i0 > mxColindex) i0 = mxColindex; /* No need, Vscl's clipping takes care of that: if (i0 < 0) i0 = 0; */
02804                   if (SV->BiasCoordVec) SV->BiasCoordVec[i] = Vscl;
02805                   if (ColMap->M[i0][0] >= 0) { /* good color */
02806                      SV->cV[i3  ] = ColMap->M[i0][0];
02807                      SV->cV[i3+1] = ColMap->M[i0][1];
02808                      SV->cV[i3+2] = ColMap->M[i0][2];
02809                   } else { /* mask color */
02810                      SV->isMasked[i] = YUP;
02811                      SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2];
02812                   }
02813                } else {
02814                   SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02815                }
02816             }
02817          } else { /* interpolation mode */
02818             SUMA_LH("Interp Mode");
02819             for (i=0; i < N_V; ++i) {
02820                i3 = 3*i;
02821                if (!SV->isMasked[i]) {
02822                   Vscl = (V[i] - Vmin) / Vrange * ColMap->N_Col; /* used mxColindex instead of N_Col (wrong!) prior to Oct 22, 03 */ 
02823                   if (Vscl < 0) Vscl = 0; if (Vscl > ColMap->N_Col) Vscl = ColMap->N_Col; /* This happens when your Min--Max are within the boundaries of the data's (V[i]) min to max */
02824                   /*now linearly interpolate between the two closest colors in the color map */
02825                   i0 = (int)(Vscl); 
02826                   if (i0 > mxColindex) i0 = mxColindex; /* No need, Vscl's clipping takes care of that: if (i0 < 0) i0 = 0; */
02827                   i1=i0+1;
02828                   if (SV->BiasCoordVec) { 
02829                      SV->BiasCoordVec[i] = Vscl; 
02830                   }
02831 
02832                   if (ColMap->M[i0][0] >= 0) { /* good color */
02833                      if (i1 < ColMap->N_Col) {
02834                         r = Vscl - i0; 
02835                         SV->cV[i3  ] = ColMap->M[i0][0] + r * (ColMap->M[i1][0] - ColMap->M[i0][0]);
02836                         SV->cV[i3+1] = ColMap->M[i0][1] + r * (ColMap->M[i1][1] - ColMap->M[i0][1]);
02837                         SV->cV[i3+2] = ColMap->M[i0][2] + r * (ColMap->M[i1][2] - ColMap->M[i0][2]);
02838                      } else {
02839                         SV->cV[i3  ] = ColMap->M[i0][0];
02840                         SV->cV[i3+1] = ColMap->M[i0][1];
02841                         SV->cV[i3+2] = ColMap->M[i0][2];
02842                      }
02843                   } else { /* mask color */
02844                      SV->isMasked[i] = YUP;
02845                      SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2];
02846                   }
02847                } else {
02848                   SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02849                }
02850             }
02851          }
02852       }else { /* all values are equal, use the middle color in the colormap */
02853          fprintf (SUMA_STDOUT,"Warning %s: Node value range is 0, using middle color in colormap.\n", FuncName);
02854          i0 = (ColMap->N_Col - 1)/2;
02855          for (i=0; i < N_V; ++i) {
02856             i3 = 3 * i;
02857             if (!SV->isMasked[i]) {
02858                if (SV->BiasCoordVec) SV->BiasCoordVec[i] = i0;
02859                SV->cV[i3  ] = ColMap->M[i0][0];
02860                SV->cV[i3+1] = ColMap->M[i0][1];
02861                SV->cV[i3+2] = ColMap->M[i0][2];
02862             } else {
02863                SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02864             }
02865          }
02866       }
02867    } else {
02868       /* direct color mapping */
02869       SUMA_LH( "Direct colormapping.\n"
02870                "Opt->IntRange values are \n"
02871                "meaningless" );
02872       if (Opt->interpmode != SUMA_DIRECT) {
02873          fprintf (SUMA_STDOUT,"Error %s: Logic error, should never get here with Opt->interpmode != SUMA_DIRECT\n", FuncName);
02874          SUMA_RETURN(NOPE);
02875       }
02876       for (i=0; i < N_V; ++i) {
02877          i3 = 3*i;
02878          if (!SV->isMasked[i]) {
02879             i0 = (int)V[i]; 
02880             if (i0 < 0) i0 = 0;
02881             else if (i0 >= ColMap->N_Col) i0 = ColMap->N_Col -1;
02882             if (ColMap->M[i0][0] >= 0) {
02883                SV->cV[i3  ] = ColMap->M[i0][0];
02884                SV->cV[i3+1] = ColMap->M[i0][1];
02885                SV->cV[i3+2] = ColMap->M[i0][2];
02886                if (SV->BiasCoordVec) SV->BiasCoordVec[i] = i0;
02887             } else {
02888                SV->isMasked[i] = YUP;
02889                SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2];
02890             }
02891          } else {
02892             SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02893          }
02894 
02895       }
02896    
02897    }
02898    
02899    /* change range for coord bias */
02900    Vrange = (Opt->CoordBiasRange[1] - Opt->CoordBiasRange[0]) / ColMap->N_Col;
02901    if (SV->BiasCoordVec) {
02902       SUMA_LH("Adding the CoordBias");
02903       for (i=0; i < N_V; ++i) {
02904             if (!SV->isMasked[i]) {
02905                SV->BiasCoordVec[i] = Opt->CoordBiasRange[0] + SV->BiasCoordVec[i] * Vrange;
02906                /* if (LocalHead) fprintf(SUMA_STDERR,"%s: %f\n", FuncName, SV->BiasCoordVec[i]); */
02907             } else SV->BiasCoordVec[i] = 0.0;
02908       }
02909    }
02910    
02911    if (Mbuf) {
02912       /* free what is in ColMap->M */
02913       SUMA_free2D((char **)ColMap->M, ColMap->N_Col);
02914       ColMap->M = Mbuf; Mbuf = NULL;
02915    }
02916    if (NewMap) {
02917       SUMA_LH("Freeing linearized colormap.");
02918       SUMA_Free_ColorMap (ColMap); 
02919    }
02920    
02921    SUMA_RETURN (YUP);
02922 } 

SUMA_Boolean SUMA_ScaleToMap_alaAFNI float *    V,
int    N_V,
float    range,
SUMA_COLOR_MAP   ColMap,
SUMA_SCALE_TO_MAP_OPT   Opt,
SUMA_COLOR_SCALED_VECT   SV
 

Definition at line 2328 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::ApplyClip, SUMA_SCALE_TO_MAP_OPT::ApplyMask, SUMA_SCALE_TO_MAP_OPT::BrightFact, SUMA_COLOR_SCALED_VECT::cV, SUMA_COLOR_MAP::frac, i, i1, SUMA_SCALE_TO_MAP_OPT::interpmode, SUMA_COLOR_SCALED_VECT::isMasked, LocalHead, SUMA_COLOR_MAP::M, SUMA_SCALE_TO_MAP_OPT::MaskColor, SUMA_SCALE_TO_MAP_OPT::MaskRange, SUMA_SCALE_TO_MAP_OPT::MaskZero, SUMA_COLOR_MAP::N_Col, r, SUMA_COLOR_MAP::Sgn, SUMA_allocate2D(), SUMA_Boolean, SUMA_DIRECT, SUMA_ENTRY, SUMA_free2D(), SUMA_Free_ColorMap(), SUMA_INTERP, SUMA_LH, SUMA_Linearize_Color_Map(), SUMA_NO_INTERP, SUMA_RETURN, SUMA_S_Warn, and SUMA_SL_Err.

Referenced by SUMA_ScaleToMap_Interactive().

02333 {
02334    static char FuncName[]={"SUMA_ScaleToMap_alaAFNI"};
02335    int i,j, i0, i1, i3, mxColindex;
02336    float Vmin, Vmax, MinCol, MaxCol, Vrange, Vscl, r, **Mbuf= NULL;
02337    SUMA_Boolean NewMap = NOPE;
02338    SUMA_Boolean LocalHead = NOPE;
02339    
02340    SUMA_ENTRY;
02341 
02342    /* Autorange ?*/
02343    
02344    if (range == 0.0) {
02345       /* autorange, find min-max values */
02346       Vmin = V[0]; Vmax = V[0];
02347       for (i=0; i < N_V; ++i) {
02348          if (V[i] > Vmax) Vmax = V[i];
02349          else if (V[i] < Vmin) Vmin = V[i];
02350       }
02351    } else {
02352       if (ColMap->Sgn >= 0) {
02353          Vmin = 0.0;
02354          Vmax = range;
02355       }else {
02356          Vmin = -range;
02357          Vmax = range;
02358       }
02359    }
02360    
02361    /* find the values to be masked out */
02362    if (Opt->ApplyMask){
02363       if (Opt->MaskZero) {
02364          /* mask zeros and values in range */
02365          for (i=0; i < N_V; ++i) {
02366             if (!V[i] || (V[i] >= Opt->MaskRange[0] && V[i] <= Opt->MaskRange[1]) ) SV->isMasked[i] = YUP;
02367          } 
02368       } else {
02369          /* don't mask zeros, just range */
02370          for (i=0; i < N_V; ++i) {
02371             if (V[i] >= Opt->MaskRange[0] && V[i] <= Opt->MaskRange[1]) SV->isMasked[i] = YUP;
02372          } 
02373       }
02374    } else {
02375       if (Opt->MaskZero) {
02376          /* mask zeros */
02377          for (i=0; i < N_V; ++i) {
02378             if (!V[i]) SV->isMasked[i] = YUP;
02379          }
02380       }
02381    }
02382    
02383    /* go through and clip values in V to those specified in the range */
02384    if (Opt->ApplyClip) {
02385       SUMA_S_Warn("Option Opt->ApplyClip not applicable here.\nOption ignored.");
02386    }
02387    for (i=0; i < N_V; ++i) {
02388       if (!SV->isMasked[i]) { /* don't waist time on masked stuff */
02389          if (V[i] > Vmin) { 
02390             /* that's cool */
02391          } else {
02392             V[i] = Vmin;
02393          }
02394 
02395          if (V[i] < Vmax) { 
02396             /* that's cool */
02397          } else {
02398             V[i] = Vmax;
02399          }
02400       } 
02401    }
02402    
02403    /* is the colormap non-linear ? */
02404    if (ColMap->frac) {
02405       /* linearize color map */
02406       SUMA_LH("Linearizing colormap ...");
02407       NewMap = YUP;
02408       if (ColMap->frac[0] > 0 && ColMap->Sgn == -1) {
02409          SUMA_S_Warn ("Color map fractions are positive with Sgn flag = -1");
02410       }
02411       if (ColMap->frac[0] < 0 && ColMap->Sgn == 1) {
02412          SUMA_S_Warn ("Color map fractions are negative with Sgn flag = 1");
02413       }
02414       ColMap = SUMA_Linearize_Color_Map (ColMap, -1);
02415       if (LocalHead) {
02416          FILE *lincmap=NULL;
02417          int ii = 0;
02418          lincmap=fopen("./lincmap.1D", "w");
02419          if (lincmap) {
02420             SUMA_LH("Linearized map written to ./lincmap.1D");
02421             /* use simple format to allow for easy read in matlab */
02422             /* SUMA_Show_ColorMapVec (&ColMap, 1, lincmap, 2); */
02423             for (ii=ColMap->N_Col-1; ii >=0; --ii) {
02424                fprintf (lincmap, "%d\t%f\t%f\t%f\n", ii, ColMap->M[ii][0], ColMap->M[ii][1],ColMap->M[ii][2]);
02425             }
02426             fclose (lincmap); lincmap = NULL;
02427          }else {
02428             SUMA_SL_Err("Failed to write linearized colormap to file.\nProceeding...");
02429          }
02430       }
02431       
02432    }else {
02433       SUMA_LH("NO Linearizing of colormap deemed necessary...");
02434       NewMap = NOPE;
02435    }
02436    
02437    /* if brightness factor is given, apply it to color map and mask color */
02438    Mbuf = NULL;
02439    if (Opt->BrightFact <= 0 || Opt->BrightFact > 1) {
02440       fprintf (SUMA_STDERR,"Error %s: Opt->BrightFact must be between ]0 1]\n", FuncName);
02441       SUMA_RETURN (NOPE);
02442    }else {
02443       if (Opt->BrightFact != 1) { 
02444          Mbuf = ColMap->M; /* save pointer */
02445          ColMap->M = (float **)SUMA_allocate2D(ColMap->N_Col, 3, sizeof(float));
02446          for (i=0; i < ColMap->N_Col; ++i) {
02447             ColMap->M[i][0] = Mbuf[i][0] * Opt->BrightFact;
02448             ColMap->M[i][1] = Mbuf[i][1] * Opt->BrightFact;
02449             ColMap->M[i][2] = Mbuf[i][2] * Opt->BrightFact;
02450          }
02451          /* now for the mask color */
02452          Opt->MaskColor[0] *= Opt->BrightFact;
02453          Opt->MaskColor[1] *= Opt->BrightFact;
02454          Opt->MaskColor[2] *= Opt->BrightFact;
02455       }
02456    }
02457    
02458    if (Opt->interpmode != SUMA_DIRECT && Opt->interpmode != SUMA_NO_INTERP && Opt->interpmode != SUMA_INTERP) {
02459       fprintf (SUMA_STDERR,"Error %s: Opt->interpmode is incorrectly specifed (%d).\n", FuncName, Opt->interpmode);
02460       SUMA_RETURN(NOPE);
02461    }
02462    
02463    if (Opt->interpmode == SUMA_INTERP || Opt->interpmode == SUMA_NO_INTERP) {
02464       /* Now go through values and interpolate onto index of colormap */
02465       MinCol = 0.0; MaxCol = (float)ColMap->N_Col; 
02466       Vrange = Vmax - Vmin; 
02467       if (LocalHead) fprintf(SUMA_STDERR,"%s: [Vrange, Vmax, Vmin] = [%f, %f, %f]\nInterpMode=%d\n", 
02468                                           FuncName, Vrange, Vmax, Vmin, Opt->interpmode);
02469       if (Vrange < 0) {
02470          fprintf (SUMA_STDERR,"Error %s: Vmax < Vmin.\n", FuncName);
02471          SUMA_RETURN (NOPE);
02472       }
02473 
02474       if (Vrange > 0) {
02475          mxColindex = ColMap->N_Col -1; 
02476          if (Opt->interpmode == SUMA_NO_INTERP) {
02477                SUMA_LH("No_Interp mode");
02478                for (i=0; i < N_V; ++i) {
02479                   i3 = 3*i;
02480                   if (!SV->isMasked[i]) {
02481                      Vscl = (V[i] - Vmin) / Vrange * ColMap->N_Col; /* used mxColindex instead of N_Col (wrong!) prior to Oct 22, 03 */
02482                      if (Vscl < 0) Vscl = 0; if (Vscl > ColMap->N_Col) Vscl = ColMap->N_Col; /* This happens when your Min--Max are within the boundaries of the data's (V[i]) min to max */
02483                      i0 = (int)(Vscl); 
02484                      if (i0 > mxColindex) i0 = mxColindex;  /* No need, Vscl's clipping takes care of that: if (i0 < 0) i0 = 0; */
02485                      if (LocalHead) {
02486                         fprintf(SUMA_STDERR,"%s: %f-->%f: Colmap index is %d\n", FuncName, V[i], Vscl, i0);
02487                      }
02488                      if (ColMap->M[i0][0] >= 0) { /* good color */
02489                         SV->cV[i3  ] = ColMap->M[i0][0];
02490                         SV->cV[i3+1] = ColMap->M[i0][1];
02491                         SV->cV[i3+2] = ColMap->M[i0][2];
02492                      } else { /* mask color */
02493                         SV->isMasked[i] = YUP;
02494                         SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2];
02495                      }
02496                   } else {
02497                      SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02498                   }
02499                   if (LocalHead) {
02500                         fprintf(SUMA_STDERR,"%s: %f-->[%f %f %f]\n", FuncName, V[i], SV->cV[i3  ], SV->cV[i3+1], SV->cV[i3+2]);
02501                   }
02502                }
02503             } else { 
02504                SUMA_LH("Interp mode");
02505                for (i=0; i < N_V; ++i) {
02506                   i3 = 3*i;
02507                   if (!SV->isMasked[i]) {
02508                      Vscl = (V[i] - Vmin) / Vrange * ColMap->N_Col; /* used mxColindex instead of N_Col (wrong!) prior to Oct 22, 03 */ 
02509                      if (Vscl < 0) Vscl = 0; if (Vscl > ColMap->N_Col) Vscl = ColMap->N_Col; /* This happens when your Min--Max are within the boundaries of the data's (V[i]) min to max */
02510                      /*now linearly interpolate between the two closest colors in the color map */
02511                      i0 = (int)(Vscl); 
02512                      if (i0 > mxColindex) i0 = mxColindex;  /* No need, Vscl's clipping takes care of that: if (i0 < 0) i0 = 0; */
02513                      i1=i0+1;
02514 
02515                      if (ColMap->M[i0][0] >= 0) { /* good color */
02516                         if (i1 < ColMap->N_Col) {
02517                            r = Vscl - i0; 
02518                            /*fprintf (SUMA_STDERR,"i0 = %d, i1 = %d, Vscl = %f, r= %f Col[i0] = %f %f %f\n", \
02519                               i0, i1, Vscl, r, ColMap->M[i0][0], ColMap->M[i0][1], ColMap->M[i0][2]);*/
02520 
02521                            SV->cV[i3  ] = ColMap->M[i0][0] + r * (ColMap->M[i1][0] - ColMap->M[i0][0]);
02522                            SV->cV[i3+1] = ColMap->M[i0][1] + r * (ColMap->M[i1][1] - ColMap->M[i0][1]);
02523                            SV->cV[i3+2] = ColMap->M[i0][2] + r * (ColMap->M[i1][2] - ColMap->M[i0][2]);
02524                         } else {
02525                            SV->cV[i3  ] = ColMap->M[i0][0];
02526                            SV->cV[i3+1] = ColMap->M[i0][1];
02527                            SV->cV[i3+2] = ColMap->M[i0][2];
02528                         }
02529                      } else { /* mask color */
02530                         SV->isMasked[i] = YUP;
02531                         SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2];
02532                      }
02533                   } else {
02534                      SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02535                   }
02536                }
02537             }
02538       } else { /* all values are equal, use the middle color in the colormap */
02539          fprintf (SUMA_STDOUT,"Warning %s: Node value range is 0, using middle color in colormap.\n", FuncName);
02540          i0 = (ColMap->N_Col - 1)/2;
02541          for (i=0; i < N_V; ++i) {
02542             i3 = 3*i;
02543             if (!SV->isMasked[i]) {
02544                if (ColMap->M[i0][0] >= 0) {
02545                   SV->cV[i3  ] = ColMap->M[i0][0];
02546                   SV->cV[i3+1] = ColMap->M[i0][1];
02547                   SV->cV[i3+2] = ColMap->M[i0][2];
02548                } else {
02549                   SV->isMasked[i] = YUP;
02550                   SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02551                }
02552             } else {
02553                SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02554             }
02555          }
02556       }
02557    } else {
02558       /* direct color mapping */
02559       SUMA_LH("Direct colormapping");
02560       if (Opt->interpmode != SUMA_DIRECT) {
02561          fprintf (SUMA_STDOUT,"Error %s: Logic error, should never get here with Opt->interpmode != SUMA_DIRECT\n", FuncName);
02562          SUMA_RETURN(NOPE);
02563       }
02564       for (i=0; i < N_V; ++i) {
02565          i3 = 3*i;
02566          if (!SV->isMasked[i]) {
02567             i0 = (int)V[i]; 
02568             if (i0 < 0) i0 = 0;
02569             else if (i0 >= ColMap->N_Col) i0 = ColMap->N_Col -1;
02570             if (ColMap->M[i0][0] >= 0) {
02571                SV->cV[i3  ] = ColMap->M[i0][0];
02572                SV->cV[i3+1] = ColMap->M[i0][1];
02573                SV->cV[i3+2] = ColMap->M[i0][2];
02574             } else {
02575                SV->isMasked[i] = YUP;
02576                SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2];
02577             }
02578          } else {
02579             SV->cV[i3  ] = Opt->MaskColor[0]; SV->cV[i3+1] = Opt->MaskColor[1]; SV->cV[i3+2] = Opt->MaskColor[2]; 
02580          }
02581 
02582       }
02583    }
02584    if (Mbuf) {
02585       /* free what is in ColMap->M */
02586       SUMA_free2D((char **)ColMap->M, ColMap->N_Col);
02587       ColMap->M = Mbuf; Mbuf = NULL;
02588    }
02589    if (NewMap) {
02590       SUMA_LH("Freeing linearized colormap.");
02591       SUMA_Free_ColorMap (ColMap); 
02592    }
02593    
02594    SUMA_RETURN (YUP);
02595    
02596 }

char* SUMA_ScaleToMapOpt_Info SUMA_SCALE_TO_MAP_OPT   OptScl,
int    detail
 

Definition at line 5422 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::alaAFNI, SUMA_SCALE_TO_MAP_OPT::ApplyClip, SUMA_SCALE_TO_MAP_OPT::ApplyMask, SUMA_SCALE_TO_MAP_OPT::AutoBrtRange, SUMA_SCALE_TO_MAP_OPT::AutoIntRange, SUMA_SCALE_TO_MAP_OPT::BiasVect, SUMA_SCALE_TO_MAP_OPT::bind, SUMA_SCALE_TO_MAP_OPT::BrightFact, SUMA_SCALE_TO_MAP_OPT::BrightMap, SUMA_SCALE_TO_MAP_OPT::BrightRange, SUMA_SCALE_TO_MAP_OPT::CoordBiasRange, SUMA_SCALE_TO_MAP_OPT::DoBias, SUMA_SCALE_TO_MAP_OPT::find, SUMA_SCALE_TO_MAP_OPT::interpmode, SUMA_SCALE_TO_MAP_OPT::IntRange, SUMA_SCALE_TO_MAP_OPT::MaskColor, SUMA_SCALE_TO_MAP_OPT::MaskRange, SUMA_SCALE_TO_MAP_OPT::MaskZero, SUMA_ENTRY, SUMA_RETURN, SUMA_SS2S, SUMA_StringAppend(), SUMA_StringAppend_va(), SUMA_SCALE_TO_MAP_OPT::ThreshRange, SUMA_SCALE_TO_MAP_OPT::ThrMode, SUMA_SCALE_TO_MAP_OPT::tind, SUMA_SCALE_TO_MAP_OPT::UseBrt, and SUMA_SCALE_TO_MAP_OPT::UseThr.

Referenced by SUMA_ColorOverlayPlane_Info(), and SUMA_ShowScaleToMapOpt().

05423 {
05424    static char FuncName[]={"SUMA_ScaleToMapOpt_Info"};
05425    char *s = NULL;
05426    SUMA_STRING *SS = NULL;
05427    
05428    SUMA_ENTRY; 
05429    SS = SUMA_StringAppend (NULL, NULL);
05430    
05431    if (!OptScl) { SS = SUMA_StringAppend (SS, "NULL ScaleToMap options\n"); }
05432    else {
05433       SS = SUMA_StringAppend (SS, "ScaleToMap options:\n");
05434       SS = SUMA_StringAppend_va (SS, "ApplyMask = %d\n", OptScl->ApplyMask);
05435       SS = SUMA_StringAppend_va (SS, "MaskRange = %f %f\n", 
05436          OptScl->MaskRange[0],  OptScl->MaskRange[1]);
05437       SS = SUMA_StringAppend_va (SS, "MaskColor = %f %f %f\n", 
05438          OptScl->MaskColor[0],  OptScl->MaskColor[1], OptScl->MaskColor[2]);
05439       SS = SUMA_StringAppend_va (SS, "ApplyClip = %d\n", OptScl->ApplyClip);
05440       SS = SUMA_StringAppend_va (SS, "BrightFact = %f\n", OptScl->BrightFact);
05441       SS = SUMA_StringAppend_va (SS, "MaskZero = %d\n", OptScl->MaskZero);
05442       SS = SUMA_StringAppend_va (SS, "find = %d\n", OptScl->find);
05443       SS = SUMA_StringAppend_va (SS, "IntRange = %f %f\n", 
05444          OptScl->IntRange[0], OptScl->IntRange[1]);
05445       SS = SUMA_StringAppend_va (SS, "AutoIntRange = %d\n", OptScl->AutoIntRange);
05446       SS = SUMA_StringAppend_va (SS, "tind = %d (use:%d). Mode %d\n", OptScl->tind, OptScl->UseThr, OptScl->ThrMode);
05447       SS = SUMA_StringAppend_va (SS, "ThreshRange = %f %f\n", 
05448          OptScl->ThreshRange[0], OptScl->ThreshRange[1]);
05449       SS = SUMA_StringAppend_va (SS, "bind = %d (use:%d)\n", OptScl->bind, OptScl->UseBrt);
05450       SS = SUMA_StringAppend_va (SS, "BrightRange = %f %f\n", 
05451          OptScl->BrightRange[0], OptScl->BrightRange[1]);
05452       SS = SUMA_StringAppend_va (SS, "BrightMap = %f %f\n", 
05453          OptScl->BrightMap[0], OptScl->BrightMap[1]);
05454       SS = SUMA_StringAppend_va (SS, "AutoBrtRange = %d\n", OptScl->AutoBrtRange);
05455       SS = SUMA_StringAppend_va (SS, "alaAFNI = %d\n", OptScl->alaAFNI);
05456       SS = SUMA_StringAppend_va (SS, "interpmode = %d\n", OptScl->interpmode);
05457       SS = SUMA_StringAppend_va (SS, "BiasMode = %d, Range=%f, %f \n", 
05458             OptScl->DoBias, OptScl->CoordBiasRange[0], OptScl->CoordBiasRange[1]);
05459       if (OptScl->BiasVect) SS = SUMA_StringAppend_va (SS, "BiasVect is NOT NULL\n");
05460          else SS = SUMA_StringAppend_va (SS, "BiasVect is NULL\n");
05461    }        
05462    SUMA_SS2S(SS, s);
05463    SUMA_RETURN(s);
05464 }

SUMA_SCALE_TO_MAP_OPT* SUMA_ScaleToMapOptInit void   
 

This function allocates for and initializes the Options structure for the function SUMA_ScaleToMap

Opt = SUMA_ScaleToMapOptInit();

\ret Opt (SUMA_SCALE_TO_MAP_OPT *) options structure with its fields initialized to the following: ApplyMask = NOPE; MaskRange[0] = MaskRange[1] = 0.0; MaskColor[0] = MaskColor[1] = MaskColor[2] = 0.0; Range[0] = Range[1] = 0.0; BrightFact = 1; interpmode = SUMA_INTERP; NULL is returned in the case of failure

You can free Opt with the free function

Definition at line 2999 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::alaAFNI, SUMA_SCALE_TO_MAP_OPT::ApplyClip, SUMA_SCALE_TO_MAP_OPT::ApplyMask, SUMA_SCALE_TO_MAP_OPT::AutoBrtRange, SUMA_SCALE_TO_MAP_OPT::AutoIntRange, SUMA_SCALE_TO_MAP_OPT::BiasVect, SUMA_SCALE_TO_MAP_OPT::bind, SUMA_SCALE_TO_MAP_OPT::BrightFact, SUMA_SCALE_TO_MAP_OPT::BrightMap, SUMA_SCALE_TO_MAP_OPT::BrightRange, SUMA_SCALE_TO_MAP_OPT::CoordBiasRange, SUMA_SCALE_TO_MAP_OPT::DoBias, SUMA_SCALE_TO_MAP_OPT::find, getenv(), SUMA_SCALE_TO_MAP_OPT::interpmode, SUMA_SCALE_TO_MAP_OPT::IntRange, SUMA_SCALE_TO_MAP_OPT::MaskColor, SUMA_SCALE_TO_MAP_OPT::MaskRange, SUMA_SCALE_TO_MAP_OPT::MaskZero, SUMA_ABS_LESS_THAN, SUMA_ENTRY, SUMA_INTERP, SUMA_LESS_THAN, SUMA_malloc, SUMA_RETURN, SW_CoordBias_None, SUMA_SCALE_TO_MAP_OPT::ThreshRange, SUMA_SCALE_TO_MAP_OPT::ThrMode, SUMA_SCALE_TO_MAP_OPT::tind, SUMA_SCALE_TO_MAP_OPT::UseBrt, and SUMA_SCALE_TO_MAP_OPT::UseThr.

Referenced by main(), SUMA_CreateOverlayPointer(), SUMA_input(), SUMA_NodeVal2irgba_nel(), and SUMA_SphereQuality().

03000 {
03001    SUMA_SCALE_TO_MAP_OPT * Opt;
03002    static char FuncName[]={"SUMA_ScaleToMapOptInit"};
03003    
03004    SUMA_ENTRY;
03005 
03006    Opt = (SUMA_SCALE_TO_MAP_OPT *)SUMA_malloc(sizeof(SUMA_SCALE_TO_MAP_OPT));
03007    
03008    if (Opt == NULL) {
03009       fprintf (SUMA_STDERR, "Error %s: Could not allocate for Opt.\n", FuncName);
03010       SUMA_RETURN (NULL);
03011    }
03012    
03013    Opt->ApplyMask = NOPE;
03014    Opt->MaskRange[0] = Opt->MaskRange[1] = 0.0;
03015    Opt->MaskColor[0] = Opt->MaskColor[1] = Opt->MaskColor[2] = 0.0; 
03016    Opt->ApplyClip = NOPE;
03017    Opt->IntRange[0] = Opt->IntRange[1] = 0.0;
03018    Opt->ThreshRange[0] = Opt->ThreshRange[1] = 0.0;
03019    Opt->BrightRange[0] = 0.0; Opt->BrightRange[1] = 0.0; 
03020    Opt->BrightMap[0] = 0.3; Opt->BrightMap[1] = 0.8; 
03021    Opt->BrightFact = 1.0;
03022    Opt->interpmode = SUMA_INTERP;
03023    Opt->alaAFNI = NOPE;
03024    Opt->AutoIntRange = YUP;
03025    Opt->AutoBrtRange = YUP;
03026    {
03027       char *eee = getenv("SUMA_MaskZero");
03028       if (eee) {
03029          if (strcmp(eee,"NO") == 0) Opt->MaskZero = NOPE;
03030          else if (strcmp(eee,"YES") == 0) Opt->MaskZero = YUP;
03031          else {
03032             fprintf (SUMA_STDERR,   "Warning %s:\n"
03033                                     "Bad value for environment variable SUMA_MaskZero\n"
03034                                     "Assuming default of YES", FuncName);
03035             Opt->MaskZero = YUP;
03036          }
03037       } else Opt->MaskZero = YUP;
03038    }
03039    
03040    Opt->find = 0;
03041    Opt->tind = 0;
03042    Opt->bind = 0;
03043    Opt->UseThr = NOPE;
03044    {
03045       char *eee = getenv("SUMA_AbsThreshold");
03046       if (eee) {
03047          if (strcmp(eee,"NO") == 0) Opt->ThrMode = SUMA_LESS_THAN;
03048          else if (strcmp(eee,"YES") == 0) Opt->ThrMode = SUMA_ABS_LESS_THAN;
03049          else {
03050             fprintf (SUMA_STDERR,   "Warning %s:\n"
03051                                     "Bad value for environment variable SUMA_AbsThresh_tbold\n"
03052                                     "Assuming default of YES", FuncName);
03053             Opt->ThrMode = SUMA_ABS_LESS_THAN;
03054          }
03055       } else Opt->ThrMode = SUMA_ABS_LESS_THAN;
03056    }
03057    
03058    Opt->UseBrt = NOPE;
03059    Opt->DoBias = SW_CoordBias_None;
03060    Opt->BiasVect = NULL;
03061    Opt->CoordBiasRange[0] = 0.0; Opt->CoordBiasRange[1] = 10.0; 
03062    SUMA_RETURN (Opt);
03063 
03064 }

SUMA_Boolean SUMA_SetConvexityPlaneDefaults SUMA_SurfaceObject   SO,
DList   DsetList
 

Sets up the defaults for the convexity plane.

Parameters:
SO  (SUMA_SurfaceObject *) pointer to surface object that the convexity dataset is attributed to.
ConvPlane  (SUMA_OVERLAYS *)

Definition at line 7413 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::ApplyClip, SUMA_SCALE_TO_MAP_OPT::bind, SUMA_SCALE_TO_MAP_OPT::BrightFact, SUMA_OVERLAYS::cmapname, SUMA_AFNI_COLORS::CMv, Cx, SUMA_SCALE_TO_MAP_OPT::find, SUMA_OVERLAYS::ForceIntRange, getenv(), SUMA_OVERLAYS::GlobalOpacity, SUMA_SurfaceObject::idcode_str, SUMA_SCALE_TO_MAP_OPT::interpmode, SUMA_SCALE_TO_MAP_OPT::IntRange, SUMA_OVERLAYS::isBackGrnd, LocalHead, SUMA_AFNI_COLORS::N_maps, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::N_Overlays, SUMA_OVERLAYS::OptScl, SUMA_SurfaceObject::Overlays, SUMA_CommonFields::scm, SUMA_OVERLAYS::Show, strtod(), SUMA_Boolean, SUMA_Build_Color_maps(), SUMA_CONVEXITY_COLORPLANE_OPACITY, SUMA_DIM_CONVEXITY_COLOR_FACTOR, SUMA_ENTRY, SUMA_Fetch_OverlayPointer(), SUMA_Find_ColorMap(), SUMA_free, SUMA_GetCx(), SUMA_LH, SUMA_NO_INTERP, SUMA_PercRange(), SUMA_RETURN, SUMA_SL_Err, SUMA_SL_Warn, SUMA_STRING_REPLACE, and SUMA_SCALE_TO_MAP_OPT::tind.

Referenced by SUMA_PrepAddmappableSO().

07414 {
07415    static char FuncName[]={"SUMA_SetConvexityPlaneDefaults"};
07416    float IntRange[2], *Vsort = NULL;
07417    float *Cx=NULL;
07418    int junk;
07419    char *eee = NULL;
07420    int icmap;
07421    SUMA_OVERLAYS *ConvPlane;
07422    SUMA_Boolean LocalHead = NOPE;
07423     
07424    SUMA_ENTRY;
07425    
07426    if (!SUMAg_CF->scm) { /* colors not setup, go back */
07427       SUMAg_CF->scm = SUMA_Build_Color_maps();
07428       if (!SUMAg_CF->scm) {
07429          SUMA_SL_Warn("No color maps set up.\n");
07430          SUMA_RETURN(YUP);
07431       }
07432    }
07433    
07434    if (!(ConvPlane = SUMA_Fetch_OverlayPointer(SO->Overlays, SO->N_Overlays, "Convexity", &junk))) {
07435       SUMA_SL_Err("Failed to find overlay plane 'Convexity'");
07436       SUMA_RETURN(NOPE);
07437    }
07438    
07439    /* decide on the color map */
07440    eee = getenv("SUMA_ConvColorMap");
07441    if (eee) {
07442       icmap = SUMA_Find_ColorMap ( eee, SUMAg_CF->scm->CMv, SUMAg_CF->scm->N_maps, -2 );
07443       if (icmap < 0) {
07444          SUMA_SL_Err("Colormap specified in\n"
07445                      "environment variable SUMA_ConvColorMap\n"
07446                      "was not found. Using ngray20.\n");
07447          SUMA_STRING_REPLACE(ConvPlane->cmapname, "ngray20");
07448      } else {
07449          SUMA_STRING_REPLACE(ConvPlane->cmapname, eee);
07450      }
07451    } else {
07452       SUMA_STRING_REPLACE(ConvPlane->cmapname, "ngray20");
07453    } 
07454 
07455    SUMA_LH("Deciding on brightness factor");   
07456    /* decide on the convexity brightness factor */
07457    eee = getenv("SUMA_ConvBrightFactor");
07458    if (eee) {
07459       ConvPlane->OptScl->BrightFact = (float)strtod(eee, NULL);
07460       if (ConvPlane->OptScl->BrightFact < 0) {
07461          SUMA_SL_Err("Brightness factor specified in\n"
07462                      "environment variable SUMA_ConvColorMap\n"
07463                      "is negative. Using default.\n");
07464          ConvPlane->OptScl->BrightFact = SUMA_DIM_CONVEXITY_COLOR_FACTOR;
07465      } 
07466    } else {
07467       ConvPlane->OptScl->BrightFact = SUMA_DIM_CONVEXITY_COLOR_FACTOR;
07468    } 
07469    
07470    /* Now place the color map in the Coloroverlay structure */
07471    ConvPlane->GlobalOpacity = SUMA_CONVEXITY_COLORPLANE_OPACITY;
07472    ConvPlane->Show = YUP;
07473    ConvPlane->isBackGrnd = YUP;
07474 
07475    SUMA_LH("Smoothing Cx");   
07476    /* work the options for creating the scaled color mapping a bit */
07477    ConvPlane->OptScl->interpmode = SUMA_NO_INTERP;
07478    ConvPlane->OptScl->ApplyClip = YUP;
07479    
07480    IntRange[0] = 5; IntRange[1] = 95; /* percentile clipping range*/ 
07481    Cx = (float *)SUMA_GetCx(SO->idcode_str, DsetList, 0);
07482    if (!Cx) { SUMA_SL_Err("Failed to find Cx\n"); SUMA_RETURN (NOPE);  }
07483    Vsort = SUMA_PercRange (Cx, NULL, SO->N_Node, IntRange, IntRange, NULL); 
07484    if (Vsort[0] < 0 && Vsort[SO->N_Node -1] > 0 ) {
07485       /* the new method */
07486       if (fabs(IntRange[0]) > IntRange[1]) {
07487          IntRange[1] = -IntRange[0];
07488       } else {
07489          IntRange[0] = -IntRange[1];
07490       }
07491    } else { 
07492      /* The old method, do nothing here */ 
07493    }
07494    if (Vsort) SUMA_free(Vsort); Vsort = NULL;
07495    
07496    ConvPlane->OptScl->find = 0; /* the intensity column */
07497    ConvPlane->OptScl->tind = 0; /* the threshold column */
07498    ConvPlane->OptScl->bind = 0; /* the brightness modulation column */
07499    ConvPlane->OptScl->IntRange[0] = IntRange[0]; ConvPlane->OptScl->IntRange[1] = IntRange[1];
07500    /* Force Auto Range to these percentile values */
07501    ConvPlane->ForceIntRange[0] = IntRange[0]; ConvPlane->ForceIntRange[1] = IntRange[1];
07502 
07503    SUMA_RETURN(YUP);
07504 }

SUMA_Boolean SUMA_SetCoordBias SUMA_OVERLAYS   ovr,
float *    NewBias,
SUMA_WIDGET_INDEX_COORDBIAS    BiasDim
 

Sets the coordinate bias for surfaces using a particular overlay plane Do NOT free NewBias upon return since this pointer will replace OptScl->BiasVect DO NOT CALL THIS FUNCTION IF ovr->NodeDef has been modified, otherwise SUMA_RemoveSO_CoordBias will fail

Definition at line 2027 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::BiasVect, SUMA_SCALE_TO_MAP_OPT::DoBias, i, SUMA_SurfaceObject::Label, LocalHead, SUMA_DO::OP, SUMA_OVERLAYS::OptScl, SUMA_Boolean, SUMA_ENTRY, SUMA_isOverlayOfSO(), SUMA_isSO(), SUMA_LH, SUMA_RETURN, SUMA_SetSO_CoordBias(), SUMA_Show_ColorOverlayPlanes(), SUMA_SL_Err, SUMA_WIDGET_INDEX_COORDBIAS, and SUMAg_N_DOv.

Referenced by SUMA_ScaleToMap_Interactive().

02028 {
02029    static char FuncName[]={"SUMA_SetCoordBias"};
02030    int i, i3, iso;
02031    SUMA_SurfaceObject *SO=NULL;
02032    SUMA_Boolean LocalHead = NOPE;
02033    SUMA_ENTRY;
02034    
02035    if (!ovr) SUMA_RETURN(YUP);
02036    
02037    if (ovr->OptScl->BiasVect ) {
02038          SUMA_SL_Err("Can't have Non NULL bias here");
02039          SUMA_Show_ColorOverlayPlanes(&ovr,1,1);
02040          SUMA_RETURN(NOPE);
02041    }
02042    
02043    for (iso=0; iso<SUMAg_N_DOv; ++iso) {
02044       if (SUMA_isSO(SUMAg_DOv[iso])) {
02045          SO = (SUMA_SurfaceObject *)SUMAg_DOv[iso].OP;
02046          if (SUMA_isOverlayOfSO(SO, ovr)) {
02047             SUMA_LH(SO->Label);
02048             SUMA_SetSO_CoordBias(SO, ovr, NewBias, BiasDim);   
02049          } 
02050       }
02051    }
02052 
02053    ovr->OptScl->BiasVect = NewBias;   
02054    ovr->OptScl->DoBias = BiasDim;
02055 
02056    SUMA_RETURN(YUP);
02057 }

SUMA_Boolean SUMA_SetSO_CoordBias SUMA_SurfaceObject   SO,
SUMA_OVERLAYS   ovr,
float *    NewBias,
SUMA_WIDGET_INDEX_COORDBIAS    BiasDim
 

Definition at line 1948 of file SUMA_Color.c.

References i, LocalHead, SUMA_OVERLAYS::N_NodeDef, SUMA_OVERLAYS::NodeDef, SUMA_SurfaceObject::NodeList, SUMA_SurfaceObject::NodeNormList, SUMA_ADD_COORD_BIAS_VECT, SUMA_Boolean, SUMA_ENTRY, SUMA_NewSurfaceGeometry(), SUMA_RETURN, SUMA_SL_Err, SUMA_WIDGET_INDEX_COORDBIAS, SW_CoordBias_N, SW_CoordBias_None, SW_CoordBias_X, SW_CoordBias_Y, and SW_CoordBias_Z.

Referenced by SUMA_SetCoordBias().

01949 {
01950    static char FuncName[]={"SUMA_SetSO_CoordBias"};
01951    int i, i3;
01952    SUMA_Boolean LocalHead = NOPE;
01953    
01954    SUMA_ENTRY;
01955    
01956    if (!ovr) { 
01957       SUMA_SL_Err("NULL ovr");
01958       SUMA_RETURN(NOPE);
01959    }
01960    if (!ovr->NodeDef) {
01961       SUMA_SL_Err("NULL ovr->NodeDef");
01962       SUMA_RETURN(NOPE);
01963    }
01964    /* Now add the new one */
01965    if (NewBias) {
01966       #if 0
01967       switch (BiasDim) {
01968          case SW_CoordBias_X:
01969             /* Add X bias */
01970             for (i=0; i < ovr->N_NodeDef; ++i) {
01971                i3 = 3*ovr->NodeDef[i];
01972                SO->NodeList[i3] += NewBias[i];
01973             }
01974             break;
01975          case SW_CoordBias_Y:
01976             /* Add Y bias */
01977             for (i=0; i < ovr->N_NodeDef; ++i) {
01978                i3 = 3*ovr->NodeDef[i]+1;
01979                SO->NodeList[i3] += NewBias[i];
01980             }
01981             break;
01982          case SW_CoordBias_Z:
01983             /* Add Z bias */
01984             for (i=0; i < ovr->N_NodeDef; ++i) {
01985                i3 = 3*ovr->NodeDef[i]+2;
01986                SO->NodeList[i3] += NewBias[i];
01987             }
01988             break;
01989          case SW_CoordBias_N:
01990             /* Add Normal bias */
01991             for (i=0; i < ovr->N_NodeDef; ++i) {
01992                i3 = 3*ovr->NodeDef[i];
01993                SO->NodeList[i3] += NewBias[i] * SO->NodeNormList[i3]; ++i3; 
01994                SO->NodeList[i3] += NewBias[i] * SO->NodeNormList[i3]; ++i3; 
01995                SO->NodeList[i3] += NewBias[i] * SO->NodeNormList[i3];  
01996             }
01997             break;
01998          case SW_CoordBias_None:
01999             /* That should not be if NewBias is not NULL */
02000             SUMA_SL_Err("Why are you calling me with SW_CoordBias_None and a non-null NewBias?");
02001             SUMA_RETURN(NOPE);
02002             break;
02003          default:
02004             SUMA_SL_Err("This should not be.\nNot at all.");
02005             SUMA_RETURN(NOPE); 
02006       }
02007       #else
02008       /* Add bias to  direction */
02009       SUMA_ADD_COORD_BIAS_VECT(SO, ovr, BiasDim, NewBias);
02010       #endif  
02011 
02012    } else {/* nothing to add (0 bias)*/
02013 
02014    }
02015 
02016    /* Update surface geometry properties */
02017    SUMA_NewSurfaceGeometry(SO);
02018    SUMA_RETURN(YUP);   
02019 }

void SUMA_Show_ColorMapVec SUMA_COLOR_MAP **    CMv,
int    N_maps,
FILE *    Out,
int    detail
 

Shows the contents of the colormaps vector.

See also:
SUMA_ColorMapVec_Info

Definition at line 925 of file SUMA_Color.c.

References LocalHead, SUMA_Boolean, SUMA_ColorMapVec_Info(), SUMA_ENTRY, SUMA_free, and SUMA_RETURNe.

Referenced by SUMA_Get_AFNI_Default_Color_Maps().

00926 {
00927    static char FuncName[]={"SUMA_Show_ColorMapVec"};
00928    char *s;
00929    SUMA_Boolean LocalHead  = NOPE;
00930    
00931    SUMA_ENTRY;
00932 
00933    
00934    if (Out == NULL) Out = stdout;
00935       
00936    s =  SUMA_ColorMapVec_Info(CMv, N_maps, detail);
00937    
00938    if (s) {
00939       fprintf (Out, "%s", s);
00940       SUMA_free(s);
00941    }else {
00942       fprintf (SUMA_STDERR, "Error %s: Failed in SUMA_ColorMapVec_Info.\n", FuncName);
00943    }   
00944    
00945 
00946    SUMA_RETURNe;
00947 }

SUMA_Boolean SUMA_Show_ColorOverlayPlanes SUMA_OVERLAYS **    Overlays,
int    N_Overlays,
int    detail
 

Function that shows the contents of overlay planes ans = SUMA_Show_ColorOverlayPlanes (SUMA_OVERLAYS **Overlays, int N_Overlays) ;

Parameters:
Overlays  (SUMA_OVERLAYS **) vector of pointers to overlay structures
N_Overlays  (int) number of overlay structures \ret ans (SUMA_Boolean)

Definition at line 5305 of file SUMA_Color.c.

References SUMA_Boolean, SUMA_ColorOverlayPlane_Info(), SUMA_ENTRY, SUMA_free, and SUMA_RETURN.

Referenced by SUMA_ColorizePlane(), SUMA_Overlays_2_GLCOLAR4(), and SUMA_SetCoordBias().

05306 {
05307    static char FuncName[]={"SUMA_Show_ColorOverlayPlanes"};
05308    char *s;
05309    
05310    SUMA_ENTRY;
05311 
05312    s = SUMA_ColorOverlayPlane_Info (Overlays, N_Overlays, detail);
05313    if (s) {
05314       fprintf (SUMA_STDERR,"%s\n", s);
05315       SUMA_free(s);
05316    }
05317    
05318    SUMA_RETURN (YUP);
05319 }

void SUMA_Show_ColorVec SUMA_RGB_NAME   CMv,
int    N_maps,
FILE *    Out
 

Shows the contents of the color vector.

See also:
SUMA_ColorVec_Info

Definition at line 900 of file SUMA_Color.c.

References SUMA_ColorVec_Info(), SUMA_ENTRY, SUMA_free, and SUMA_RETURNe.

Referenced by SUMA_Get_AFNI_Default_Color_Maps().

00901 {
00902    static char FuncName[]={"SUMA_Show_ColorVec"};
00903    char *s;
00904    
00905    SUMA_ENTRY;
00906 
00907    if (Out == NULL) Out = stdout;
00908       
00909    s =  SUMA_ColorVec_Info(CMv, N_maps);
00910    
00911    if (s) {
00912       fprintf (Out, "%s", s);
00913       SUMA_free(s);
00914    }else {
00915       fprintf (SUMA_STDERR, "Error %s: Failed in SUMA_ColorVec_Info.\n", FuncName);
00916    }   
00917    
00918    SUMA_RETURNe;
00919 }

SUMA_Boolean SUMA_ShowScaleToMapOpt SUMA_SCALE_TO_MAP_OPT   OptScl,
FILE *    Out,
int    detail
 

Definition at line 5404 of file SUMA_Color.c.

References SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_RETURN, and SUMA_ScaleToMapOpt_Info().

05405 {
05406    static char FuncName[]={"SUMA_ShowScaleToMapOpt"};
05407    char *s=NULL;
05408    
05409    SUMA_ENTRY;
05410    
05411    if (!Out) Out = stdout;
05412    
05413    s = SUMA_ScaleToMapOpt_Info(OptScl, detail);
05414    
05415    fprintf (Out, "%s\n", s);
05416    
05417    if (s) SUMA_free(s); s = NULL;
05418    
05419    SUMA_RETURN(YUP);
05420 }

SUMA_STANDARD_CMAP SUMA_StandardMapCode char *    Name
 

Returns the code corresponding to a colormap name.

See also:
SUMA_StandardMapName

Definition at line 3149 of file SUMA_Color.c.

References SUMA_CMAP_BGYR19, SUMA_CMAP_BGYR64, SUMA_CMAP_BW20, SUMA_CMAP_ERROR, SUMA_CMAP_flpGRAY02, SUMA_CMAP_GRAY02, SUMA_CMAP_GRAY20, SUMA_CMAP_MATLAB_DEF_BYR64, SUMA_CMAP_nGRAY20, SUMA_CMAP_RGYBR20, SUMA_CMAP_ROI128, SUMA_CMAP_ROI256, SUMA_CMAP_ROI64, SUMA_CMAP_UNDEFINED, SUMA_ENTRY, SUMA_RETURN, SUMA_STANDARD_CMAP, and SUMA_TO_LOWER.

Referenced by SUMA_cb_AfniLink_toggled().

03150 {
03151    static char FuncName[]={"SUMA_StandardMapCode"};
03152    
03153    SUMA_ENTRY;
03154    
03155    if (!Name) SUMA_RETURN(SUMA_CMAP_ERROR);
03156    SUMA_TO_LOWER(Name);
03157    if (!strcmp(Name, "undefined")) SUMA_RETURN(SUMA_CMAP_UNDEFINED);
03158    if (!strcmp(Name, "rgybr20")) SUMA_RETURN(SUMA_CMAP_RGYBR20);
03159    if (!strcmp(Name, "ngray20")) SUMA_RETURN(SUMA_CMAP_nGRAY20);
03160    if (!strcmp(Name, "gray20")) SUMA_RETURN(SUMA_CMAP_GRAY20);
03161    if (!strcmp(Name, "gray02")) SUMA_RETURN(SUMA_CMAP_GRAY02);
03162    if (!strcmp(Name, "gray_i02")) SUMA_RETURN(SUMA_CMAP_flpGRAY02);
03163    if (!strcmp(Name, "bw20")) SUMA_RETURN(SUMA_CMAP_BW20);
03164    if (!strcmp(Name, "bgyr19")) SUMA_RETURN(SUMA_CMAP_BGYR19);
03165    if (!strcmp(Name, "matlab_default_byr64")) SUMA_RETURN(SUMA_CMAP_MATLAB_DEF_BYR64);
03166    if (!strcmp(Name, "byr64")) SUMA_RETURN(SUMA_CMAP_MATLAB_DEF_BYR64);
03167    if (!strcmp(Name, "bgyr64")) SUMA_RETURN(SUMA_CMAP_BGYR64);
03168    if (!strcmp(Name, "ygbrp64")) SUMA_RETURN(SUMA_CMAP_ROI64);
03169    if (!strcmp(Name, "roi64")) SUMA_RETURN(SUMA_CMAP_ROI64);
03170    if (!strcmp(Name, "ygbrp128")) SUMA_RETURN(SUMA_CMAP_ROI128);
03171    if (!strcmp(Name, "ygbrp256")) SUMA_RETURN(SUMA_CMAP_ROI256);
03172    if (!strcmp(Name, "roi128")) SUMA_RETURN(SUMA_CMAP_ROI128);
03173    if (!strcmp(Name, "roi256")) SUMA_RETURN(SUMA_CMAP_ROI256);
03174    /* if (!strcmp(Name, "")) SUMA_RETURN(); */
03175    SUMA_RETURN(SUMA_CMAP_ERROR);
03176 }

char* SUMA_StandardMapName SUMA_STANDARD_CMAP    mapcode,
int *    N_col
 

Returns the ascii name of a Suma standard map.

Parameters:
mapcode  (SUMA_STANDARD_CMAP)
N_col  (int *) to contain the number of colors in the map -1 if no map was found
Returns:
ans (char *) ascii version of mapcode
See also:
SUMA_StandardMapCode

Definition at line 3076 of file SUMA_Color.c.

References SUMA_CMAP_BGYR19, SUMA_CMAP_BGYR64, SUMA_CMAP_BW20, SUMA_CMAP_ERROR, SUMA_CMAP_flpGRAY02, SUMA_CMAP_GRAY02, SUMA_CMAP_GRAY20, SUMA_CMAP_MATLAB_DEF_BYR64, SUMA_CMAP_nGRAY20, SUMA_CMAP_RGYBR20, SUMA_CMAP_ROI128, SUMA_CMAP_ROI256, SUMA_CMAP_ROI64, SUMA_CMAP_UNDEFINED, SUMA_ENTRY, SUMA_RETURN, and SUMA_STANDARD_CMAP.

Referenced by SUMA_GetStandardMap(), and SUMA_Paint_SO_ROIplanes().

03077 {
03078    static char FuncName[]={"SUMA_StandardMapName"};
03079    
03080    SUMA_ENTRY;
03081    
03082    *N_col = -1;
03083    switch (mapcode) {
03084       case SUMA_CMAP_ERROR:
03085          SUMA_RETURN("Error");
03086          break;
03087       case SUMA_CMAP_UNDEFINED:
03088          SUMA_RETURN("Undefined");
03089          break;
03090       case SUMA_CMAP_RGYBR20:
03091          *N_col = 20;
03092          SUMA_RETURN("rgybr20");
03093          break;
03094       case SUMA_CMAP_nGRAY20:
03095          *N_col = 20;
03096          SUMA_RETURN("ngray20");
03097          break;
03098       case SUMA_CMAP_GRAY02:
03099          *N_col = 02;
03100          SUMA_RETURN("gray02");
03101          break;
03102       case SUMA_CMAP_flpGRAY02:
03103          *N_col = 02;
03104          SUMA_RETURN("gray_i02");
03105          break;
03106       case SUMA_CMAP_GRAY20:
03107          *N_col = 20;
03108          SUMA_RETURN("gray20");
03109          break;
03110       case SUMA_CMAP_BW20:
03111          *N_col = 20;
03112          SUMA_RETURN("bw20");
03113          break;
03114       case SUMA_CMAP_BGYR19:
03115          *N_col = 19;
03116          SUMA_RETURN("bgyr19");
03117          break;
03118       case SUMA_CMAP_MATLAB_DEF_BYR64:
03119          *N_col = 64;
03120          SUMA_RETURN("byr64");
03121          break;
03122       case SUMA_CMAP_BGYR64:
03123          *N_col = 64;
03124          SUMA_RETURN("bgyr64");
03125          break;
03126       case SUMA_CMAP_ROI256:
03127          *N_col = 256;
03128          SUMA_RETURN("roi256");
03129          break;
03130       case SUMA_CMAP_ROI128:
03131          *N_col = 128;
03132          SUMA_RETURN("roi128");
03133          break;
03134       case SUMA_CMAP_ROI64:
03135          *N_col = 64;
03136          SUMA_RETURN("roi64");
03137          break;
03138       default:
03139          SUMA_RETURN("Cowabonga-x321");
03140          break;
03141    }
03142 }

SUMA_Boolean SUMA_TransferCoordBias SUMA_OVERLAYS   ovr,
SUMA_WIDGET_INDEX_COORDBIAS    BiasDim
 

Definition at line 1768 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::DoBias, LocalHead, SUMA_DO::OP, SUMA_OVERLAYS::OptScl, SUMA_Boolean, SUMA_ENTRY, SUMA_isOverlayOfSO(), SUMA_isSO(), SUMA_LH, SUMA_RETURN, SUMA_TransferSO_CoordBias(), SUMA_WIDGET_INDEX_COORDBIAS, and SUMAg_N_DOv.

Referenced by SUMA_cb_SetCoordBias().

01769 {
01770    static char FuncName[]={"SUMA_TransferCoordBias"};
01771    SUMA_SurfaceObject *SO=NULL;
01772    int iso;
01773    SUMA_Boolean LocalHead = NOPE;
01774    SUMA_ENTRY;
01775    
01776    if (!ovr) SUMA_RETURN(YUP);
01777       
01778    for (iso=0; iso<SUMAg_N_DOv; ++iso) {
01779       if (SUMA_isSO(SUMAg_DOv[iso])) {
01780          SO = (SUMA_SurfaceObject *)SUMAg_DOv[iso].OP;
01781          if (SUMA_isOverlayOfSO(SO, ovr)) {
01782             SUMA_TransferSO_CoordBias(SO, ovr, BiasDim);   
01783          } 
01784       }
01785    }
01786 
01787    SUMA_LH("Setting bias flag");
01788    ovr->OptScl->DoBias = BiasDim;
01789 
01790    SUMA_RETURN(YUP);
01791 
01792 }

SUMA_Boolean SUMA_TransferSO_CoordBias SUMA_SurfaceObject   SO,
SUMA_OVERLAYS   ovr,
SUMA_WIDGET_INDEX_COORDBIAS    BiasDim
 

Single surface version of SUMA_TransferCoordBias DO NOT CALL THIS FUNCTION OUTSIDE OF SUMA_TransferCoordBias

Definition at line 1797 of file SUMA_Color.c.

References SUMA_SCALE_TO_MAP_OPT::BiasVect, SUMA_SCALE_TO_MAP_OPT::DoBias, i, LocalHead, SUMA_OVERLAYS::N_NodeDef, SUMA_OVERLAYS::NodeDef, SUMA_SurfaceObject::NodeList, SUMA_SurfaceObject::NodeNormList, SUMA_OVERLAYS::OptScl, SUMA_ADD_COORD_BIAS_VECT, SUMA_Boolean, SUMA_ENTRY, SUMA_LH, SUMA_NewSurfaceGeometry(), SUMA_RETURN, SUMA_SL_Err, SUMA_WIDGET_INDEX_COORDBIAS, SW_CoordBias_N, SW_CoordBias_X, SW_CoordBias_Y, and SW_CoordBias_Z.

Referenced by SUMA_TransferCoordBias().

01798 {
01799    static char FuncName[]={"SUMA_TransferSO_CoordBias"};
01800    SUMA_Boolean LocalHead = NOPE;
01801    int i, i3;
01802       
01803    SUMA_ENTRY;
01804    
01805    SUMA_LH("Called");
01806    
01807    
01808    if (ovr->OptScl->BiasVect) {
01809       SUMA_LH("Removing old bias"); 
01810       /* Remove old bias */
01811       switch (ovr->OptScl->DoBias) {
01812          case SW_CoordBias_X:
01813             /* Remove X bias */
01814             for (i=0; i < ovr->N_NodeDef; ++i) {
01815                i3 = 3*ovr->NodeDef[i];
01816                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i];
01817             }
01818             break;
01819          case SW_CoordBias_Y:
01820             /* Remove Y bias */
01821             for (i=0; i < ovr->N_NodeDef; ++i) {
01822                i3 = 3*ovr->NodeDef[i]+1;
01823                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i];
01824             }
01825             break;
01826          case SW_CoordBias_Z:
01827             /* Remove Z bias */
01828             for (i=0; i < ovr->N_NodeDef; ++i) {
01829                i3 = 3*ovr->NodeDef[i]+2;
01830                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i];
01831             }
01832             break;
01833          case SW_CoordBias_N:
01834             /* Remove Normal bias */
01835             for (i=0; i < ovr->N_NodeDef; ++i) {
01836                i3 = 3*ovr->NodeDef[i];
01837                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3]; ++i3; 
01838                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3]; ++i3; 
01839                SO->NodeList[i3] -= ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3];  
01840             }
01841             break;
01842          default:
01843             SUMA_SL_Err("This should not be");
01844             SUMA_RETURN(NOPE);
01845       }
01846       SUMA_LH("Adding new bias");
01847       
01848       #if 0
01849       /* Add same bias to other direction */
01850       switch (BiasDim) {
01851          case SW_CoordBias_X:
01852             /* Add X bias */
01853             for (i=0; i < ovr->N_NodeDef; ++i) {
01854                i3 = 3*ovr->NodeDef[i];
01855                SO->NodeList[i3] += ovr->OptScl->BiasVect[i];
01856             }
01857             break;
01858          case SW_CoordBias_Y:
01859             /* Add Y bias */
01860             for (i=0; i < ovr->N_NodeDef; ++i) {
01861                i3 = 3*ovr->NodeDef[i]+1;
01862                SO->NodeList[i3] += ovr->OptScl->BiasVect[i];
01863             }
01864             break;
01865          case SW_CoordBias_Z:
01866             /* Add Z bias */
01867             for (i=0; i < ovr->N_NodeDef; ++i) {
01868                i3 = 3*ovr->NodeDef[i]+2;
01869                SO->NodeList[i3] += ovr->OptScl->BiasVect[i];
01870             }
01871             break;
01872          case SW_CoordBias_N:
01873             /* Add Normal bias */
01874             for (i=0; i < ovr->N_NodeDef; ++i) {
01875                i3 = 3*ovr->NodeDef[i];
01876                SO->NodeList[i3] += ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3]; ++i3; 
01877                SO->NodeList[i3] += ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3]; ++i3; 
01878                SO->NodeList[i3] += ovr->OptScl->BiasVect[i] * SO->NodeNormList[i3];  
01879             }
01880             break;
01881          default:
01882             SUMA_SL_Err("This should not be.\nWhy, oh why ?");
01883             SUMA_RETURN(NOPE);
01884       }
01885       #else 
01886       /* Add same bias to other direction */
01887       SUMA_ADD_COORD_BIAS_VECT(SO, ovr, BiasDim, ovr->OptScl->BiasVect);
01888       #endif
01889    }
01890    
01891    /* Update surface geometry properties */
01892    SUMA_NewSurfaceGeometry(SO);
01893    SUMA_RETURN(YUP);
01894 }
 

Powered by Plone

This site conforms to the following standards: