Thursday, August 20, 2015

resizing matrices in Matlab

In my previous post, I'd mentioned processing 2-D matrices to put them into relevant rows and columns instead of just 5 numbers per line. This rearrangement of matrix elements uses the reshape function. In our case,
A_rz=reshape(A_rz',1,numel(A_rz));
A_rz=reshape(A_rz,30,30);
A_rz=A_rz';

using MCML - Monte Carlo light transport in multi-layered scattering media

is referenced in Wang and Wu's Biomedical Optics. Some points I noted for its usage are given below, in addition to the documentation available in the book as well as the included paper in the download.

  • I used Fabrice Bellard's Tiny C compiler to re-compile the code on Windows. It's only a 386 kB standalone download, as against gcc's MinGW and CygWin options which are installers which download more files.
  • After extracting the zip file, you can add its location to the path variable - Control Panel -> System ->  Advanced -> Environment Variables, and then restart the system, or add it to the commandline for a temporary session.
  • Compile, link and create executable with just
    tcc -o mcml.exe mcmlmain.c mcmlgo.c mcmlio.c mcmlnr.c
    Done in less than a second.
  • Incident light angle has direction cosines (0,0,1) by default, can change in mcmlgo.c
  • The output 2-D arrays of Tt_ra, Rd_ra, A_rz are formatted in the ASCII output file as 5 numbers per line(!) and not as lines and columns related to the 2-D array. This can be modified in mcmlio.c - or, of course, when the array is imported into something like Matlab, it needs further processing.
  • Large txt files are created by mcml in case large numbers are specified for dz, dr and da - these will need txt file editors which can handle large files. Files upto a few hundred MB were OK with PsPad, other options are gVim etc as noted here.
  • Section 3.5 of the Biomedical Optics book talks about overflow in the grid - we have to note this - that the last grid element in the direction of the overflow collects the weight - and have to discard that point. In reconstruction Fig 3.4, for eg, the first grid element reading has to be discarded - T_t(0). - or perhaps this is because the measured value is T_t (total transmittance) and what we need is T_d (diffuse transmittance). The angle a (or alpha) in R_d(a) is angle of reflection, so it goes from 0 to pi/2.
  • Section 3.5 also talks about how we should choose the grid size - numbers of da, dz and dr along with values of dz and dr - as a rule of thumb, each grid element should measure about 10% of penetration depth or transport mean free path.

Friday, August 14, 2015

free up space on C drive - MSOCache

Wanted to free up space on C drive. Found this superuser post about moving MSOCache folder to another drive. The mklink solution suggested there did not work, probably because I am on Windows XP and not Win7. But I did the registry editing technique, using advanced regedit to find and replace C:\MSOCache with D:\MSOCache

extracting data from open UDF session

We received some data on a DVD which had an open UDF session - DVD session had not been closed. On Mac and on Windows explorer, the disc displays as empty. Nero Burning Rom's Disc Info showed the open session, but my DVD writer has some writing issues, so I was unable to close the session with Nero 8. The writer which is working is on a machine which has Nero 6, which does not have the Finalize session option. Googled for closing UDF session, and videohelp forums pointed to ISO buster. I had ISO buster, which was able to extract the files with no issues.

Sunday, August 09, 2015

USB printer issues

A TVS MSP 345 dot matrix printer connected using a parallel to USB converter cable to the laptop's USB port did not print today. Tried re-installing the driver, still no go. Then, cycled through the three virtual printer ports in printer properties -> ports,  USB001, USB002 and USB003. It finally worked with USB003.