Index: DataLoader/readers/IgorReader.py
===================================================================
--- DataLoader/readers/IgorReader.py	(revision 0e2aa401c5c88b919e06b360988f04e12a916c8e)
+++ DataLoader/readers/IgorReader.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -32,4 +32,6 @@
     """ Simple data reader for Igor data files """
     ## File type
+    type_name = "IGOR 2D"   
+    ## Wildcards
     type = ["IGOR 2D files (*.ASC)|*.ASC"]
     ## Extension
Index: DataLoader/readers/__init__.py
===================================================================
--- DataLoader/readers/__init__.py	(revision bbc8013228fef1315e9d7137b8ef24ad4a8da943)
+++ DataLoader/readers/__init__.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -1,25 +1,5 @@
-import abs_reader
-import cansas_reader
-import ascii_reader
-import cansas_reader
-import danse_reader
-import hfir1d_reader
-import IgorReader
-import tiff_reader
+# Backward compatibility with the previous implementation of the default readers
+from associations import register_readers
 
-def register_readers(registry_function):
-    """
-        Function called by the registry/loader object to register
-        all default readers using a call back function.
-    
-        @param registry_function: function to be called to register each reader
-    """
-    registry_function(abs_reader)
-    registry_function(cansas_reader)
-    registry_function(ascii_reader)
-    registry_function(cansas_reader)
-    registry_function(danse_reader)
-    registry_function(hfir1d_reader)
-    registry_function(IgorReader)
-    registry_function(tiff_reader)
-    
+# Method to associate extensions to default readers 
+from associations import read_associations
Index: DataLoader/readers/abs_reader.py
===================================================================
--- DataLoader/readers/abs_reader.py	(revision 0e2aa401c5c88b919e06b360988f04e12a916c8e)
+++ DataLoader/readers/abs_reader.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -24,4 +24,6 @@
     """
     ## File type
+    type_name = "IGOR 1D"   
+    ## Wildcards
     type = ["IGOR 1D files (*.abs)|*.abs"]
     ## List of allowed extensions
Index: DataLoader/readers/ascii_reader.py
===================================================================
--- DataLoader/readers/ascii_reader.py	(revision 0e2aa401c5c88b919e06b360988f04e12a916c8e)
+++ DataLoader/readers/ascii_reader.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -25,4 +25,7 @@
     """
     ## File type
+    type_name = "ASCII"
+    
+    ## Wildcards
     type = ["ASCII files (*.txt)|*.txt",
             "ASCII files (*.dat)|*.dat",
Index: DataLoader/readers/associations.py
===================================================================
--- DataLoader/readers/associations.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
+++ DataLoader/readers/associations.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -0,0 +1,132 @@
+"""
+This software was developed by the University of Tennessee as part of the
+Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+project funded by the US National Science Foundation. 
+
+See the license text in license.txt
+
+copyright 2009, University of Tennessee
+"""
+
+"""
+    Module to associate default readers to file extensions.
+    The module reads an xml file to get the readers for each file extension.
+    The readers are tried in order they appear when reading a file.
+"""
+
+import os, sys
+from xml import xpath
+import xml.dom.minidom 
+import logging
+
+from xml.dom.minidom import parse
+
+## Format version for the XML settings file
+VERSION = '1.0'
+
+def get_node_text(node):
+    """
+        Get the text context of a node
+        
+        @param node: node to read from
+        @return: content, attribute list
+    """
+    content = None
+    attr    = {}
+    for item in node.childNodes:
+        if item.nodeName.find('text')>=0 \
+            and len(item.nodeValue.strip())>0:
+            content = item.nodeValue.strip()
+            break
+        
+    if node.hasAttributes():
+        for i in range(node.attributes.length):
+            attr[node.attributes.item(i).nodeName] \
+                = node.attributes.item(i).nodeValue
+
+    return content, attr
+
+def read_associations(loader, path='defaults.xml'):
+    """
+        Read the specified settings file to associate
+        default readers to file extension.
+        
+        @param loader: Loader object
+        @param path: path to the XML settings file
+    """
+    reader_dir = os.path.dirname(__file__)
+    path = os.path.join(reader_dir, path)
+    
+    if os.path.isfile(path):
+        dom = parse(path)
+        
+        # Check the format version number
+        nodes = xpath.Evaluate('SansLoader', dom)
+        if nodes[0].hasAttributes():
+            for i in range(nodes[0].attributes.length):
+                if nodes[0].attributes.item(i).nodeName=='version':
+                    if nodes[0].attributes.item(i).nodeValue != VERSION:
+                        raise ValueError, "associations: unrecognized SansLoader version number %s" % \
+                            nodes[0].attributes.item(i).nodeValue
+        
+        # Read in the file extension associations
+        entry_list = xpath.Evaluate('SansLoader/FileType', dom)
+        for entry in entry_list:
+            value, attr = get_node_text(entry)
+            if attr is not None \
+                and attr.has_key('reader') and attr.has_key('extension'):
+                
+                # Associate the extension with a particular reader
+                # TODO: Modify the Register code to be case-insensitive and remove the
+                #       extra line below.
+                try:
+                    exec "import %s" % attr['reader']
+                    exec "loader.associate_file_type('%s', %s)" % (attr['extension'].lower(), attr['reader'])
+                    exec "loader.associate_file_type('%s', %s)" % (attr['extension'].upper(), attr['reader'])
+                except:
+                    logging.error("read_associations: skipping association for %s\n  %s" % (attr['extension'], sys.exc_value))
+         
+         
+def register_readers(registry_function):
+    """
+        Function called by the registry/loader object to register
+        all default readers using a call back function.
+        
+        WARNING: this method is now obsolete
+    
+        @param registry_function: function to be called to register each reader
+    """
+    import abs_reader
+    import cansas_reader
+    import ascii_reader
+    import cansas_reader
+    import danse_reader
+    import hfir1d_reader
+    import IgorReader
+    import tiff_reader
+
+    registry_function(abs_reader)
+    registry_function(cansas_reader)
+    registry_function(ascii_reader)
+    registry_function(cansas_reader)
+    registry_function(danse_reader)
+    registry_function(hfir1d_reader)
+    registry_function(IgorReader)
+    registry_function(tiff_reader)
+    
+    return True            
+
+
+if __name__ == "__main__": 
+    logging.basicConfig(level=logging.INFO,
+                        format='%(asctime)s %(levelname)s %(message)s',
+                        filename='logger.log',
+                        filemode='w')
+    from DataLoader.loader import Loader
+    l = Loader()
+    read_associations(l)
+    
+    
+    print l.get_wildcards()
+    
+    
Index: DataLoader/readers/cansas_reader.py
===================================================================
--- DataLoader/readers/cansas_reader.py	(revision 0e2aa401c5c88b919e06b360988f04e12a916c8e)
+++ DataLoader/readers/cansas_reader.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -196,4 +196,6 @@
     version = '1.0'
     ## File type
+    type_name = "CanSAS 1D"
+    ## Wildcards
     type = ["CanSAS 1D files (*.xml)|*.xml"]
     ## List of allowed extensions
Index: DataLoader/readers/danse_reader.py
===================================================================
--- DataLoader/readers/danse_reader.py	(revision 0e2aa401c5c88b919e06b360988f04e12a916c8e)
+++ DataLoader/readers/danse_reader.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -36,4 +36,6 @@
     """
     ## File type
+    type_name = "DANSE"   
+    ## Wildcards
     type = ["DANSE files (*.sans)|*.sans"]
     ## Extension
Index: DataLoader/readers/defaults.xml
===================================================================
--- DataLoader/readers/defaults.xml	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
+++ DataLoader/readers/defaults.xml	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<SansLoader version="1.0"
+    xmlns="sansloader/1.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    >
+	<FileType extension='.abs' reader='abs_reader'/>
+	<FileType extension='.abs' reader='ascii_reader'/>
+	
+	<FileType extension='.txt' reader='ascii_reader'/>
+	<FileType extension='.dat' reader='ascii_reader'/>
+
+	<FileType extension='.xml' reader='cansas_reader'/>
+	
+	<FileType extension='.sans' reader='danse_reader'/>
+	
+	<FileType extension='.d1d' reader='hfir1d_reader'/>
+	
+	<FileType extension='.asc' reader='IgorReader'/>
+	
+	<FileType extension='.tif' reader='tiff_reader'/>
+	<FileType extension='.tiff' reader='tiff_reader'/>
+    
+</SansLoader>
+
Index: DataLoader/readers/hfir1d_reader.py
===================================================================
--- DataLoader/readers/hfir1d_reader.py	(revision 0e2aa401c5c88b919e06b360988f04e12a916c8e)
+++ DataLoader/readers/hfir1d_reader.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -25,4 +25,6 @@
     """
     ## File type
+    type_name = "HFIR 1D"   
+    ## Wildcards
     type = ["HFIR 1D files (*.d1d)|*.d1d"]
     ## List of allowed extensions
Index: DataLoader/readers/old_tiff_reader.py
===================================================================
--- DataLoader/readers/old_tiff_reader.py	(revision c35e84924894e58f9883670f1f505e7a22342185)
+++ 	(revision )
@@ -1,102 +1,0 @@
-"""
-    Image reader. Untested. 
-"""
-
-"""
-This software was developed by the University of Tennessee as part of the
-Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-project funded by the US National Science Foundation. 
-
-See the license text in license.txt
-
-copyright 2008, University of Tennessee
-"""
-#TODO: load and check data and orientation of the image (needs rendering)
-
-import math, logging, os
-import numpy
-from DataLoader.data_info import Data2D
-    
-class Reader:
-    """
-        Example data manipulation
-    """
-    ## File type
-    type = ["TIF files (*.tif)|*.tif",
-            "JPG files (*.jpg)|*.jpg",
-            "JPEG files (*.jpeg)|*.jpeg",
-            "PNG files (*.png)|*.png",
-            "TIFF files (*.tiff)|*.tiff",
-            "BMP files (*.bmp)|*.bmp",
-            "GIF files (*.gif)|*.gif",
-            ]
-    ## Extension
-    ext  = ['.tif', '.jpg', '.png', '.jpeg', '.tiff', '.gif', '.bmp']    
-        
-    def read(self, filename=None):
-        """
-            Open and read the data in a file
-            @param file: path of the file
-        """
-        try:
-            import Image
-        except:
-            raise RuntimeError, "tiff_reader: could not load file. Missing Image module."
-        
-        # Instantiate data object
-        output = Data2D()
-        output.filename = os.path.basename(filename)
-            
-        # Read in the image
-        try:
-            im = Image.open(filename)
-        except :
-            raise  RuntimeError,"cannot open %s"%(filename)
-        data = im.getdata()
-
-        # Initiazed the output data object
-        output.data = numpy.zeros([im.size[0],im.size[1]])
-        
-        # Initialize 
-        x_vals = []
-        y_vals = [] 
-
-        # x and y vectors
-        for i_x in range(im.size[0]):
-            x_vals.append(i_x)
-            
-        itot = 0
-        for i_y in range(im.size[1]):
-            y_vals.append(i_y)
-
-        for val in data:
-            try:
-                value = float(val)
-            except:
-                logging.error("tiff_reader: had to skip a non-float point")
-                continue
-            
-            # Get bin number
-            if math.fmod(itot, im.size[0])==0:
-                i_x = 0
-                i_y += 1
-            else:
-                i_x += 1
-                
-            output.data[im.size[1]-1-i_y][i_x] = value
-            
-            itot += 1
-                
-        output.xbins      = im.size[0]
-        output.ybins      = im.size[1]
-        output.x_bins     = x_vals
-        output.y_bins     = y_vals
-        output.xmin       = 0
-        output.xmax       = im.size[0]-1
-        output.ymin       = 0
-        output.ymax       = im.size[0]-1
-        
-        return data#output
-        
-
-
Index: DataLoader/readers/tiff_reader.py
===================================================================
--- DataLoader/readers/tiff_reader.py	(revision 9d4e5027e5d1f4802be758166e1d774b9447b997)
+++ DataLoader/readers/tiff_reader.py	(revision 28caa03404030faac2dd29ba6ae3e5afc427a99b)
@@ -23,20 +23,11 @@
     """
     ## File type
+    type_name = "TIF"   
+    ## Wildcards
     type = ["TIF files (*.tif)|*.tif",
-            "JPG files (*.jpg)|*.jpg",
-            "JPEG files (*.jpeg)|*.jpeg",
-            "PNG files (*.png)|*.png",
             "TIFF files (*.tiff)|*.tiff",
-            "BMP files (*.bmp)|*.bmp",
-            "GIF files (*.gif)|*.gif",
             ]
     ## Extension
-    ext  = ['.tif','.TIF',
-             '.jpg','.JPG',
-              '.png','.PNG',
-               '.jpeg','.JPEG',
-                '.tiff','.TIFF',
-                 '.gif','.GIF',
-                  '.bmp', '.BMP']    
+    ext  = ['.tif', '.tiff']    
         
     def read(self, filename=None):
@@ -59,12 +50,10 @@
         except :
             raise  RuntimeError,"cannot open %s"%(filename)
-        predata = im.load()
+        data = im.getdata()
 
-        x_range = im.size[0]
-        y_range = im.size[1]
+        # Initiazed the output data object
+        output.data = numpy.zeros([im.size[0],im.size[1]])
+        output.err_data = numpy.zeros([im.size[0],im.size[1]])
         
-        # Initiazed the output data object
-        output.data = numpy.zeros([y_range,x_range])
-        output.err_data = numpy.zeros([y_range,x_range])
         # Initialize 
         x_vals = []
@@ -72,43 +61,44 @@
 
         # x and y vectors
-        for i_x in range(x_range):
+        for i_x in range(im.size[0]):
             x_vals.append(i_x)
             
-        
-        for i_y in range(y_range):
+        itot = 0
+        for i_y in range(im.size[1]):
             y_vals.append(i_y)
-        
-        for i_x in range(x_range):
-            for i_y in range(y_range):
+
+        for val in data:
+            try:
+                value = float(val)
+            except:
+                logging.error("tiff_reader: had to skip a non-float point")
+                continue
             
-                try:
-                    if predata[i_x,i_y].__class__.__name__=="tuple":                     
-                        
-                        if len(predata[i_x,i_y]) == 3:   
-                            R,G,B= predata[i_x,i_y]
-                        elif len(predata[i_x,i_y]) == 4:   
-                            R,G,B,I = predata[i_x,i_y]
-                        #Converting to L Mode: uses the ITU-R 601-2 luma transform.
-                        value = float(R * 299/1000 + G * 587/1000 + B * 114/1000) 
-                         
-                    else:
-                        #Take it as Intensity
-                        value = float(predata[i_x,i_y])
-                except:
-                    logging.error("tiff_reader: had to skip a non-float point")
-                    continue
+            # Get bin number
+            if math.fmod(itot, im.size[0])==0:
+                i_x = 0
+                i_y += 1
+            else:
+                i_x += 1
                 
-                  
-                output.data[y_range-i_y-1,i_x] = value
-        
-        output.xbins      = x_range
-        output.ybins      = y_range
+            output.data[im.size[1]-1-i_y][i_x] = value
+            
+            itot += 1
+                
+        output.xbins      = im.size[0]
+        output.ybins      = im.size[1]
         output.x_bins     = x_vals
         output.y_bins     = y_vals
         output.xmin       = 0
-        output.xmax       = x_range-1
+        output.xmax       = im.size[0]-1
         output.ymin       = 0
-        output.ymax       = y_range-1
+        output.ymax       = im.size[0]-1
         
         return output
         
+
+if __name__ == "__main__": 
+    reader = Reader()
+    print reader.read("../test/MP_New.sans")
+    
+
