cansas1d casestudy collagen: Difference between revisions

From canSAS
(develop a case study as an example of how to get data into the standard)
 
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Overview=
= Overview =


[[Image:Cs-collagen-data-table-Excel.jpg|thumb|case study: Collagen, SAXS data in Excel table]]
[[Image:Cs-collagen-data-table-Excel.jpg|thumb|case study: Collagen, SAXS data in Excel table]]
Line 6: Line 6:
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).
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.'''
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 raw data was collected on a linear position-sensitive detector and reduced to columns of '''Q''', '''I''', and '''Iesd''' (estimated standard deviation of '''I''').
Line 12: Line 12:
The only metadata available for this data (without resorting to digging through piles of old notebooks) was obtained from two file headers:
The only metadata available for this data (without resorting to digging through piles of old notebooks) was obtained from two file headers:


[http://svn.smallangles.net/trac/canSAS/browser/1dwg/trunk/examples/collagen/COLLAGEN.ASC  collagen.asc]
<pre>
<pre>
Sep 19 1994    01:41:02 am    Elt: 00090 Seconds  
Sep 19 1994    01:41:02 am    Elt: 00090 Seconds  
Line 18: Line 19:
</pre>
</pre>


[http://svn.smallangles.net/trac/canSAS/browser/1dwg/trunk/examples/collagen/collagen.saxs  collagen.saxs]
<pre>
<pre>
dry chick collagen, d = 673 A
dry chick collagen, d = 673 A
Line 23: Line 25:
</pre>
</pre>


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


=Procedure=
= Procedure =


==make the basic XML file==
== make the basic XML file ==


It is easiest to copy a template rather than start from an empty 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'''.
Copy the [http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xml cansas1d.xml] file into your working directory and rename it to '''collagen.xml'''.


==modify collagen.xml==
==modify collagen.xml==
Line 43: Line 45:
<pre>
<pre>
<?xml version="1.0"?>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="example.xsl" ?>
<SASroot version="1.0"
<SASroot version="1.0"
xmlns="http://www.smallangles.net/cansas1d"
    xmlns="cansas1d/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
    xsi:schemaLocation="cansas1d/1.0 http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd"
http://www.smallangles.net/cansas1d/  
    >
http://www.smallangles.net/cansas1d/1.0/cansas1d.xsd
"
>
<SASentry>
<SASentry>
<Title>dry chick collagen, d = 673 A, 6531 eV, X6B</Title>
<Title>dry chick collagen, d = 673 A, 6531 eV, X6B</Title>
Line 85: Line 85:
</SASroot>
</SASroot>
</pre>
</pre>
== 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.
<pre>
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
</pre>
Your window will look similar to this one when you copy/paste the above code:
[[Image:Cs-collagen-macro-editing.jpg|thumb|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
<pre>=IDATA_tag(A5,$A$4,B5,$B$4,C5,$C$4)</pre>
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 <nowiki><!-- Idata lines will go here --></nowiki>.
= 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  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 [[cansas1d_documentation#Validation_of_XML_against_the_Schema|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/ http://svn.smallangles.net/trac/canSAS/browser/1dwg/trunk/examples/collagen/]

Latest revision as of 03:38, 23 March 2008

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/