cansas1d casestudy collagen

From canSAS

Overview

case study: Collagen, SAXS data in Excel table
case study: Collagen, SAXS data in Excel chart

To demonstrate how to get SAS data into the XML standard format, consider this set of SAXS data collected at the National Synchrotron Light Source, Brookhaven National Laboratory, using a SAXS camera set up temporarily at beam line X6B (operated by the Materials Science Division, Argonne National Lab).

The sample was dry chick collagen. (Thanks to Malcolm Capel, NSLS beam line X12C for the sample.)

The raw data was collected on a linear position-sensitive detector and reduced to columns of Q, I, and Iesd (estimated standard deviation of I).

The only metadata available for this data (without resorting to digging through piles of old notebooks) was obtained from two file headers:

collagen.asc

Sep 19 1994     01:41:02 am     Elt: 00090 Seconds 
ID: No spectrum identifier defined
Memory Size: 8192 Chls  Conversion Gain: 1024  Adc Offset: 0000 Chls

collagen.saxs

dry chick collagen, d = 673 A
6531 eV, X6B

But, the data can fulfill the minimum requirements of the 1D standard file format and also make an excellent example of a minimal canSAS reduced 1-D SAS data file in XML.

Procedure

make the basic XML file

It is easiest to copy a template rather than start from an empty file. Copy the cansas1d.xml file into your working directory and rename it to collagen.xml.

modify collagen.xml

It is easier to see the metadata in the XML file before you enter the SAXS data into the file. With the brief metadata available, most lines can be eliminated. This will result in a file that looks like

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="example.xsl" ?>
<SASroot version="1.0"
    xmlns="cansas1d/1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="cansas1d/1.0 http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd"
    >
	<SASentry>
		<Title>dry chick collagen, d = 673 A, 6531 eV, X6B</Title>
		<Run />
		<SASdata>
		   <!-- Idata lines will go here -->
		</SASdata>
		<SASsample>
			<ID>dry chick collagen, d = 673 A, 6531 eV, X6B</ID>
		</SASsample>
		<SASinstrument>
			<name>X6B, NSLS, BNL</name>
			<SASsource>
				<radiation>X-ray synchrotron</radiation>
				<wavelength unit="A">
				   1.898
				   <!-- = 12398/6531 --> 
				</wavelength>
			</SASsource>
			<SAScollimation />
			<SASdetector>
				<name>X6B PSD</name>
			</SASdetector>
		</SASinstrument>
		<SASnote>
Sep 19 1994     01:41:02 am     Elt: 00090 Seconds 
ID: No spectrum identifier defined
Memory Size: 8192 Chls  Conversion Gain: 1024  Adc Offset: 0000 Chls

dry chick collagen, d = 673 A
6531 eV, X6B
		</SASnote>
	</SASentry>
</SASroot>

prepare the SAXS data

Microsoft Excel is used here to convert the table of SAXS data into the required lines of XML for the standard. Some may prefer to use a cell formula but here, we develop a bit of Excel Macro code to clarify our procedure.

Excel macros used

Within Excel, with the SAXS data in columns as shown above (Media:Cs-collagen-data-table-Excel.jpg), let's define the macros for our use. In Excel, type <alt><F11> to open the macro editing window.

Function XML_tag(tag, attr, content) As String
  If attr = "" Then
    XML = "<" & tag & ">"
  Else
    XML = "<" & tag & " " & attr & ">"
  End If
  XML = XML & content
  XML = XML & "</" & tag & ">"
  XML_tag = XML
End Function

Function SAS_Idata_tag(element, unit, content) As String
  XML = XML_tag(element, "unit=""" & unit & """", content)
  SAS_Idata_tag = XML
End Function

Function Idata_tag(Q, Q_unit, I, I_unit, Idev, Idev_unit) As String
  XML = SAS_Idata_tag("Q", Q_unit, Q)
  XML = XML & SAS_Idata_tag("I", I_unit, I)
  XML = XML & SAS_Idata_tag("Idev", Idev_unit, Idev)
  Idata_tag = XML_tag("Idata", "", XML)
End Function

Your window will look similar to this one when you copy/paste the above code:

case study: Collagen, SAXS data in Excel chart

(Yes, my spreadsheet is called MyFirstMacro.xls)

Now close the macro editing window and return to the SAXS data in the spreadsheet.

construct the Idata lines in XML

move to spreadsheet cell E5 and enter this formula

=IDATA_tag(A5,$A$4,B5,$B$4,C5,$C$4)

Copy it down through cell E335

Select cells E5:E335 and copy to clipboard, then paste into collagen.xml document inside the SASdata element where you see the XML comment <!-- Idata lines will go here -->.

Final Result

A nicely-formatted display version of the final result can be viewed through the TRAC repository: http://svn.smallangles.net/trac/canSAS/browser/1dwg/trunk/cs_collagen_full.xml

Validate your file

So you think you have an XML file. Let's validate it using the procedure from the documentation. All the instructions are on the documentation page. No sense in repeating them here.

References

All files are available at http://svn.smallangles.net/trac/canSAS/browser/1dwg/trunk/examples/collagen/