• Home
  • Introduction
  • Software
  • About me

Looking At Nothing

A SA(X)S Weblog

Category:

  • Clear Presentation Initiative
  • LookingAtNothing Weblog
  • Matlab
  • misc.
  • Movies
  • Paper review
  • Papers
  • Particle size distribution
  • Posters
  • Pushbutton machines
  • sampleholder design
  • SAXSGUI software
  • software
  • Uncategorized

Archives:

  • August 2010
  • July 2010
  • June 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • February 2009
  • November 2008
  • October 2008
  • July 2008
  • May 2008
  • February 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007

Blogroll:

  • Nico Adams
  • Presentation zen

Meta:

  • RSS
  • Comments RSS
  • Valid XHTML
  • XFN

“Perfect” 1D pattern generation software.

August 30th, 2010 by Brian

I have written some small, simple bits of Matlab software that can generate scattering patterns in the range you request for polydisperse, dilute spheres or ellipsoids. While nothing new per se, this implementation is guaranteed to produce correct scattering patterns irrespective of the width of the distribution. Allow me to quickly explain.

The normal way of calculating these patterns in fitting functions and the likes, is to choose an upper size limit (perhaps related to the width and mean of the distribution), and divide the size range between zero and this upper limit into perhaps 100 different sizes. Then the scattering pattern of each of these contributions is calculated, multiplied with their probability (obtained from the probability (or size) distribution function), multiplied with the square of the particle volume for that size, and then summed. In all, then, this is a numeric integration over the volume-square weighted size distribution.

The problem lies in the determination of the upper limit and the number of divisions required. In the past, I have tried using the cumulative distribution function to select “smart” divisions, or adjusting the width and mean to compensate for the volume-square weighting, but this often resulted in the appearance of oscillatory behaviour in the scattering patterns. An alternative solution was therefore required.

These functions are not necessarily fast enough for fitting purposes, but they can be used for checking the applicability of your fitting procedures. You should get out of your fitting functions what you put into these simulated patterns.

These functions work by random generation of a number of spheres or ellipsoids. A scattering pattern is calculated from an initial number of spheres or ellipsoids. Then, the scattering pattern is calculated of the original block with the addition of a new set of shapes. This is repeated until the effect of adding a new block on the scattering pattern no longer exceeds a certain threshold.

Included are the programs for generating scattering patterns using polydisperse distributions of spheres or ellipsoids. All distributions supported by the “statistics library”’s RANDOM function are available. For ellipsoids, an additional distribution can be used for the aspect ratio. If the use is not clear, let me know and I will write some more extensive documentation.

The programs are: perfectpattern_spheres and perfectpattern_ellipsoids. Have fun!

Posted in Uncategorized | No Comments

Teaching and how it applies to us.

August 22nd, 2010 by Brian

We teach. Every one of us. If we have a classroom of students, it is obvious, but also when we talk to colleagues, we sometimes try to teach them something (even if it is only our point of view).

I spoke last time about the teaching horrors that modern textbooks have. Well, this video by Dan Meyer explains why the textbooks are absolutely not helping to teach by asking the questions wrong, and he proposes an alternative way to pose the questions. He also, by the way, has a nice blog full of examples of how to get a class of students to actually think.

This gets me thinking. How can we apply this to our presentations? Are we really engaging our audience by starting with a “talk outline”, or should we pose the final question as simple as possible and work from there? I will be experimenting with this and I will let you know how it goes!

Posted in Uncategorized | 1 Comment

Read Ruland and more free reading (textbooks!)

August 16th, 2010 by Brian

Catching up to current affairs, I stumbled across this beauty. Now, I find this paper starts a little bit chaotic, but very quickly we come across some very useful equations indeed, and a link between the used equation for their analysis of phase transitions in fluids, and various other equations such as the Ornstein-Zernike structure factor and the Debye-Bueche equation. The equations published in this paper appear ready to be applied to a wide variety of amorphous scattering patterns, capable of extracting quite a few physical parameters! There will likely be much more on this topic as I get to apply these. To top it all off, the data used in the paper has been “extracted” from published graphics by Ms. A. Höhle. I can see her sitting there now with a ruler and a paper, meticulously noting down her estimates for the q and S values for each datapoint…. Perhaps it would be a good starting point for publishing some of our best data online so others can have a go at analysing it?

On another note, I want to point you towards the horror of textbooks. How fitting then, that the next special issue of the J. of Appl. Cryst. is about teaching! As you may have read on Slashdot a few weeks ago, textbooks are still very expensive, even for topics as stagnant as elementary mathematics. prof. Feynman also had a few words to say on the topic of textbooks. And there are now some alternatives popping up allowing your students an alternative to ridiculous and expensive textbooks: Free textbooks.

http://www.curriki.org/xwiki/bin/view/Main/WebHome

http://about.ck12.org/

http://www.lightandmatter.com/

http://www.wikibooks.org/

If you know more, let me know and I will add them to the list!

Posted in Uncategorized | No Comments

Quick update

June 5th, 2010 by Brian

Hi all,

I am not abandoning you, I am merely in the middle of a string of four experiments divided over three beamtimes in an almost consecutive span of 10 days, which required preparation and lots of catch-up sleep in between. I have something useful coming up soon, and a publication in print as well, which I’ll be happy to share with you once it is out (August).

Yours sincerely,

Brian.

Posted in Uncategorized | No Comments

Alternative Ellipsoid Form Factor Function

April 30th, 2010 by Brian
Just a quick heads up before I start on the ellipsoid form factor alternative: I spoke last post of the efforts for data archiving for possible open-access purposes. Shortly after that post, this news (http://news.bbc.co.uk/2/hi/uk_news/northern_ireland/8623417.stm) appeared. It seems we may be heading (more rapidly than I thought) towards an age where we have to make data public, which means archiving with metadata and storing in an archival format. I do hope (Matlab) writing and reading functions for NeXus format (http://www.nexusformat.org/) files become available soon.
Regarding the ellipsoid form factor, I have mainly been using the ellipsoid adaptation to the Rayleigh sphere scattering function. However, this function requires integration over all orientations (see f.ex. equation 3.46 in the SASfit manual) http://kur.web.psi.ch/sans1/sasfit/sasfit.pdf

Just a quick heads up before I start on the ellipsoid form factor alternative: I spoke last post of the efforts for data archiving for possible open-access purposes. Shortly after that post, this news appeared. It seems we may be heading (more rapidly than I thought) towards an age where we have to make data public, which means archiving with metadata and storing in an archival format. I do hope (Matlab) writing and reading functions for NeXus format files become available soon.

Regarding the ellipsoid form factor, I have mainly been using the ellipsoid adaptation to the Rayleigh sphere scattering function. However, this function requires integration over all orientations (see f.ex. equation 3.46 in the SASfit manual). This becomes very time-consuming for use as a fitting function if you furthermore would like to integrate over minor- and main-axis size distributions.

An alternative form factor appears to have been published in a light-scattering paper in 1969 [1] by Beattie and Tisinger. Although this procedure requires an iterative approach, it may prove to be faster to use than the aforementioned method. Efforts are underway to implement this method. Assistance, as always, is highly appreciated.

[1] Beattie and Tisinger. Light Scattering Functions and Particle-Scattering Factors for Ellipsoids of Revolution. Journal of the Optical Society of America (1969) vol. 59 pp. 818

Posted in Uncategorized | No Comments

Archival/universal file format

April 20th, 2010 by Brian

At the 3-way meeting last week, there was some discussion into general file formats for beamlines. The argument for them is that when beamlines and scientific institutes will be asked to open their research data to the general public (perhaps after a certain period has expired, just like the astronomy community apparently has to), it should be published in a readable format with enough metadata attached to uniquely identify the experiment and conditions.

While it sounds like a lot of extra work (and there is a barrier to extra work, as we have enough to do as it is), the idea of using such a format as an archival and interchange format is one that appeals to me. The Astronomy community could agree on a format, but X-ray and neutron scattering communities have discussed plenty and reached (let’s be honest) not much yet. Whether that is because there is as yet no need for such a universal file format or whether it needs to be more flexible than it can ever support is not known. All I know is that a file format I made for my experiments, containing the calibrated and corrected data, has saved me a lot of time.

At the 3-way meeting, there was consensus that the file format should be gently forced by the management upon the beamlines. However, it was also agreed that money needs to be spent hiring full-time employees to set up, maintain and support the file format. Finally, it was agreed that the NeXus file format is the format to go for.

With that in mind, I contacted the community to ask whether I can write NeXus files from Matlab (the only language I know). In short, the file format can be read, but writing tools are not yet implemented. This will involve the inclusion of Java classes into the Matlab environment, a method I am unfortunately unfamiliar with. As the effort continues, I will let you know once more is available.

Posted in Uncategorized | No Comments

Bayesian Inverse Fourier Transforms

March 31st, 2010 by Brian

Although I cannot say I completely grasp the underlying theory, the Bayesian approach to the Inverse Fourier Transformation of (isotropic) small-angle scattering patterns certainly appeals to me. The idea is that the small-angle scattering pattern can be transformed (back) into real-space, resulting in either a distance distribution function p(r), a correlation function gamma(r) (=r^2 p(r) ), or through double derivation of the result, into a chord length distribution (CLD). The Bayesian approach removes the user-defined input requirements of the standard IFT.

So what can you do with all this real-space information? Well, first of all, being in real space means that one’s intuition can once more be applied (because intuition does not work in reciprocal space). For example: a maximum probability at a certain radius really may indicate that this is a characteristic length scale in the system. Secondly, the real-space p(r) may be a lot easier to fit than the scattering pattern itself, especially for odd shapes for which no analytical scattering function exists. Lastly, it shows exactly the amount of information inherent in the SA(X)S pattern, making it easier for those new in the field to understand the limits of the number of extractable parameters.

More about this in future posts. If you’re interested, I can point towards the following references:

Hansen. Bayesian estimation of hyperparameters for indirect Fourier transformation in small-angle scattering. Journal of Applied Crystallography (2000) vol. 33 pp. 1415-1421

Hansen. Estimation of chord length distributions from small-angle scattering using indirect Fourier transformation. Journal of Applied Crystallography (2003) vol. 36 pp. 1190-1196

Hansen. Simultaneous estimation of the form factor and structure factor for globular particles in small-angle scattering. J Appl Crystallogr (2008) vol. 41 pp. 436-445

Pons et al. Modeling of chord length distributions. Chem Eng Sci (2006) vol. 61 (12) pp. 3962-3973

Hansen. Bayesian estimation of hyperparameters for indirect Fourier transformation in small-angle scattering. Journal of Applied Crystallography (2000) vol. 33 pp. 1415-1421
Hansen. Estimation of chord length distributions from small-angle scattering using indirect Fourier transformation. Journal of Applied Crystallography (2003) vol. 36 pp. 1190-1196
Hansen. Simultaneous estimation of the form factor and structure factor for globular particles in small-angle scattering. J Appl Crystallogr (2008) vol. 41 pp. 436-445
Pons et al. Modeling of chord length distributions. Chem Eng Sci (2006) vol. 61 (12) pp. 3962-3973

Posted in Uncategorized | No Comments

TED is coming to Europe this summer!

February 27th, 2010 by Brian

Good news for all of you keeping up with current affairs in the worlds of Technology, Entertainment and Design: There is a TED conference coming to Europe this summer! So if you are unwilling to travel to the US, you can now travel to the UK instead, and join the conference from 12-16th of July in Oxford. Registration and information available here: http://conferences.ted.com/TEDGlobal2010/

I probably will not be able to convince my boss that this is a conference I need to attend, and I’ll be in Japan that time, so I think I may unfortunately have to miss it due to a lack of funds. But for all of you that are going, let me know how it was!

Posted in Uncategorized | No Comments

Speeding up the Bessel function

January 18th, 2010 by Brian

The Bessel function is used in a few scattering functions, for example in that of a cylinder. The implementation of the Bessel function in Matlab is quite slow, however, which annoyed me considerably as it slowed down my fitting functions. I therefore had a look at whether I could speed it up.

The paper by Frank B. Gross entitled “New approximations to J0 and J1 Bessel functions” (IEEE transactions on antennas and propagation vol. 43, no. 8, 1995, pp.904) seemed like a good place to start. It is mentioned there that there are two fast approximations already available, i.e. the “small argument approximation”, valid for x<0.5 and the “large argument approximation”, valid for x>5, which are very quick functions indeed. However, for 0.5<x<5, the only approximation available was a Taylor series.

dr. Gross then comes up with a new approximation expressed as a polynomial with integer coefficients. The only drawback of this implementation, is that for the first order Bessel function J1, it requires the calculation of the derivative at x, and would therefore require either more points, or would put stringent requirements on the order and spacing of x.

In a later paper by Millane and Eads (IEEE transactions on antennas and propagation, 2003, vol. 51, no. 6, pp. 1398) the approximation derived by Gross is further generalised to encompass all Bessel functions of integer order. More interestingly, it does away with the derivation. However, I could not get their approximation to result in the correct values.

The last paper that “solved” the issue is a paper from 2006 by Li (and Gross, Applied mathematics and computation 2006, 183, pp. 1220), which generalises the generalisation by Millane and Eads to obtain an approximation for the Bessel functions for all fractional order. This contains an equation which provides a good and quick approximation to the Bessel function.

When implemented, however, it could not beat the internal function in Matlab. The speed reached by the approximation was virtually identical to that of the internal Matlab function. Now, while this was not a great success, it can be considered a partial success, as my interpreted code was as fast as the optimized, internal code. Of course, it remains an approximation…

Finally, I tried simply using a linear interpolation between several results of the Bessel function between 0<x<5, and using the large argument approximation beyond that. This gives moderately good results, as it is two to three times faster as the internal Matlab function. While not much faster, it has certainly taught me a lot about Bessel function implementations. If there is anyone among you out there with knowledge on how to compile Matlab functions into optimized code, please let me know.

Cheers,

Brian.

Posted in Uncategorized | No Comments

A successful 2010 to all of you!

December 31st, 2009 by Brian

During the past few months I have defended my thesis successfully and I have started work as a post-doc at Aarhus University working on SAXS studies of reactions under supercritical conditions. I will update this website in 2010 as well, so keep tuning in!

I wish everyone a very successful (and fun) 2010!

Posted in Uncategorized | No Comments

« Previous Entries

 
Wordpress Themes by and Website Templates by Blogcut