<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Research: Math, Computing and MRI &#187; Computing</title>
	<atom:link href="http://mri.brechmos.org/category/computing/feed/" rel="self" type="application/rss+xml" />
	<link>http://mri.brechmos.org</link>
	<description>by Craig Jones</description>
	<lastBuildDate>Wed, 10 Aug 2011 16:53:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Reading Raw Data in Python</title>
		<link>http://mri.brechmos.org/2010/02/reading-raw-data-in-python/</link>
		<comments>http://mri.brechmos.org/2010/02/reading-raw-data-in-python/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 02:25:50 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=559</guid>
		<description><![CDATA[In a similar vein to reading raw data into Matlab, I created a similar type of function in Python: [cc lang="python"] def readraw(filename, shape, intype=&#8217;int16&#8242;, byteSwap=False): &#8220;&#8221;" readraw &#8211; To read in a raw file and reformat it to the &#8230; <a href="http://mri.brechmos.org/2010/02/reading-raw-data-in-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In a similar vein to <a href="http://mri.brechmos.org/2010/02/01/reading-raw-data-in-matlab/">reading raw data into Matlab</a>, I created a similar type of function in Python:</p>
<p>[cc lang="python"]<br />
def readraw(filename, shape, intype=&#8217;int16&#8242;, byteSwap=False):<br />
        &#8220;&#8221;" readraw &#8211; To read in a raw file and reformat it to the right shape &#8220;&#8221;"</p>
<p>        #  Read in the file<br />
        if filename.endswith(&#8216;gz&#8217;):<br />
                fp = gzip.open(filename, &#8216;rb&#8217;)<br />
        else:<br />
                fp = open(filename, &#8216;rb&#8217;)</p>
<p>        d = fromfile(file=fp, dtype=intype).reshape(shape)</p>
<p>        d.byteswap(byteSwap)</p>
<p>        return d<br />
[/cc]</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2010/02/reading-raw-data-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading raw data in Matlab</title>
		<link>http://mri.brechmos.org/2010/02/reading-raw-data-in-matlab/</link>
		<comments>http://mri.brechmos.org/2010/02/reading-raw-data-in-matlab/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 02:20:07 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=555</guid>
		<description><![CDATA[One of the most common things I do in Matlab almost always involves reading in binary data.  For a few years I went through the typical [cci lang="matlab"]fp=fopen(&#8216;filename.dat&#8217;&#8230;[/cci].  After typing the fopen, fread, reshape and fclose too many times, I &#8230; <a href="http://mri.brechmos.org/2010/02/reading-raw-data-in-matlab/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most common things I do in Matlab almost always involves reading in binary data.  For a few years I went through the typical [cci lang="matlab"]fp=fopen(&#8216;filename.dat&#8217;&#8230;[/cci].  After typing the fopen, fread, reshape and fclose too many times, I finally made it into an all-in-one Matlab function called [cci lang="matlab"]readraw()[/cci] which will do all the reading and reformatting in one function call.</p>
<p>[cc lang="matlab"]<br />
function [d] = readraw(filename, type, ds, endian)</p>
<p>if( nargin == 3 )<br />
	endian = &#8216;b&#8217;;<br />
end</p>
<p>fp=fopen(filename, &#8216;rb&#8217;, endian);<br />
d = fread(fp, prod(ds), type);<br />
fclose(fp);</p>
<p>d = reshape(d, ds);<br />
[/cc]</p>
<p>There isn&#8217;t much magic here, just a simple idea that I use almost daily.</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2010/02/reading-raw-data-in-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Huge Java Resource</title>
		<link>http://mri.brechmos.org/2010/01/huge-java-resource/</link>
		<comments>http://mri.brechmos.org/2010/01/huge-java-resource/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 04:49:12 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=545</guid>
		<description><![CDATA[I have been working on some numerical problems in the last few weeks.  Mostly related to curve fitting and interpolation.  I am slowly sliding back to Java bit-by-bit though I am not sure if I will give up Python as &#8230; <a href="http://mri.brechmos.org/2010/01/huge-java-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-546" href="http://mri.brechmos.org/2010/01/27/huge-java-resource/flanagan/"><img class="alignright size-medium wp-image-546" title="flanagan" src="http://mri.brechmos.org/wp-content/uploads/2010/01/26/huge-java-resource/flanagan-385x450.png" alt="" width="385" height="450" /></a>I have been working on some numerical problems in the last few weeks.  Mostly related to curve fitting and interpolation.  I am slowly sliding back to Java bit-by-bit though I am not sure if I will give up Python as the syntax is so tight and it is actually very fast.</p>
<p>Anyway, I was looking around for some curve fitting and interpolation code on the Net and found Michael Flannigan&#8217;s <a href="http://www.ee.ucl.ac.uk/~mflanaga">website</a> which has a great resource of math, stats, optimization and some other  more subtle items.  His Java code is <a href="http://www.ee.ucl.ac.uk/~mflanaga/java/">here</a>.</p>
<p>I can&#8217;t even do it justice by showing the list of packages as it is about twice as long as the screen capture shown to the right.</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2010/01/huge-java-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show SQL table output using PHP</title>
		<link>http://mri.brechmos.org/2010/01/show-sql-table-output-using-php/</link>
		<comments>http://mri.brechmos.org/2010/01/show-sql-table-output-using-php/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 02:21:27 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=29</guid>
		<description><![CDATA[I found this code on the internet. This is a nice bit of code to show an arbitrary table with headers and all the entries. There is probably lots more one could do with it, but it works well for &#8230; <a href="http://mri.brechmos.org/2010/01/show-sql-table-output-using-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I <a title="http://forum.siteground.com/archive/index.php/t-12434.html" rel="nofollow" href="http://forum.siteground.com/archive/index.php/t-12434.html"> found</a> this code on the internet. This is a nice bit of code to show an arbitrary table with headers and all the entries. There is probably lots more one could do with it, but it works well for general testing and is completely independent of what is in the table.</p>
<p>[cc lang="php"]<br />
function display($table)<br />
{<br />
	$db_host = &#8216;localhost&#8217;;<br />
	$db_user = &#8216;<userid here>&#8216;;<br />
	$db_pwd = &#8216;
<password here>&#8216;;<br />
 <br />
	$database = &#8216;<sql database here>&#8216;;<br />
 <br />
	if (!mysql_connect($db_host, $db_user, $db_pwd))<br />
	    die(&#8220;Can&#8217;t connect to database&#8221;);<br />
 <br />
	if (!mysql_select_db($database))  ||  die(&#8220;Can&#8217;t select database&#8221;);<br />
 <br />
	// sending query<br />
	$result = mysql_query(&#8220;SELECT * FROM {$table}&#8221;);<br />
	if (!$result) {<br />
	    die(&#8220;Query to show fields from table failed&#8221;);<br />
	}<br />
 <br />
	$fields_num = mysql_num_fields($result);<br />
 <br />
	echo &#8220;<br />
<h1>;Table: {$table}</h1>
<p>&#8220;;<br />
	echo &#8220;<br />
<table border='1'>
<tr>&#8220;;<br />
	// printing table headers<br />
	for($i=0; $i<$fields_num; $i++)<br />
	{<br />
	    $field = mysql_fetch_field($result);<br />
	    echo "
<td>{$field->name}</td>
<p>&#8220;;<br />
	}<br />
	echo &#8220;</tr>
<p>\n&#8221;;<br />
	// printing table rows<br />
	while($row = mysql_fetch_row($result))<br />
	{<br />
	    echo &#8220;<br />
<tr>&#8220;;<br />
 <br />
	    // $row is array&#8230; foreach( .. ) puts every element<br />
	    // of $row to $cell variable<br />
	    foreach($row as $cell)<br />
		echo &#8220;
<td>$cell</td>
<p>&#8220;;<br />
 <br />
	    echo &#8220;</tr>
<p>\n&#8221;;<br />
	}<br />
        echo &#8220;</table>
<p>&#8220;;<br />
	mysql_free_result($result);<br />
}<br />
[/cc]</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2010/01/show-sql-table-output-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backups and Revision Control</title>
		<link>http://mri.brechmos.org/2010/01/backups-and-revision-control/</link>
		<comments>http://mri.brechmos.org/2010/01/backups-and-revision-control/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 21:20:26 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=27</guid>
		<description><![CDATA[I seem to be always looking for a reasonable way to use revision control on my home directory (lots of binary files and text files). There is a great comparison of different revision control systems, including Git. I like Git, &#8230; <a href="http://mri.brechmos.org/2010/01/backups-and-revision-control/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I seem to be always looking for a reasonable way to use revision control on my home directory (lots of binary files and text files). There is a great comparison of different revision control systems, including Git. I like Git, a little complex, but it is nice. There is a great <a title="http://crunchbanglinux.org/wiki/revision_controlled_home_directory" rel="nofollow" href="http://crunchbanglinux.org/wiki/revision_controlled_home_directory"> writeup</a> about using Git for revision control which includes automating the add/commit cycle reasonably often.</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2010/01/backups-and-revision-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python, Scipy and Numpy</title>
		<link>http://mri.brechmos.org/2009/06/python-scipy-and-numpy/</link>
		<comments>http://mri.brechmos.org/2009/06/python-scipy-and-numpy/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 18:30:42 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Matlab]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=102</guid>
		<description><![CDATA[For approximately 16 years I have been using Matlab faithfully.  Back when I started (1993) all it had were 2D matrices and I remember having to use a package someone wrote up to have 3D volume capabilities (which are typically &#8230; <a href="http://mri.brechmos.org/2009/06/python-scipy-and-numpy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For approximately 16 years I have been using Matlab faithfully.  Back when I started (1993) all it had were 2D matrices and I remember having to use a package someone wrote up to have 3D volume capabilities (which are typically required for processing MRI datasets).  Matlab is great, don&#8217;t get me wrong.  There are few things that I don&#8217;t like about it.</p>
<p>So, sitting at a conference in Hawaii (tough life, I know) I had some ideas that I wanted to try out and quickly figured out that I could not get to the site license hosts back at my university.  Argh.  So, I started looking around to see if there were other options which would provide me a similar feel and processing capabilities.  There were a few options, but the one that stuck out was to use <a href="http://www.python.org">Python</a>, <a href="http://www.scipy.org/">Scipy</a> and <a href="http://numpy.scipy.org/">Numpy</a>.  They were almost tailor made for what I wanted.</p>
<p>So, over the last little while I have been using the Python, Scipy, Numpy triad for most of my research and am feeling like I want to shift over completely the triad rather than using Matlab.</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2009/06/python-scipy-and-numpy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passwordless Login Using SSH</title>
		<link>http://mri.brechmos.org/2009/05/passwordless-login-using-ssh/</link>
		<comments>http://mri.brechmos.org/2009/05/passwordless-login-using-ssh/#comments</comments>
		<pubDate>Sat, 16 May 2009 02:44:33 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=165</guid>
		<description><![CDATA[Computer c1 – connect from this computer Computer c2 – connect to this computer 1. Connect to c1 2. type: ssh-keygen -t rsa -b 2048 * default directory for keyfiles will be ~/.ssh/ * if you do not want to &#8230; <a href="http://mri.brechmos.org/2009/05/passwordless-login-using-ssh/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Computer c1 – connect from this computer</p>
<p>Computer c2 – connect to this computer</p>
<p>1. Connect to c1<br />
2. type: ssh-keygen -t rsa -b 2048<br />
* default directory for keyfiles will be ~/.ssh/<br />
* if you do not want to be prompted, leave passphrase blank<br />
3. copy the contents of .ssh/id_rsa.pub (there should only be one line)<br />
4. place this line on c2, in ~/.ssh/authorized_keys</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2009/05/passwordless-login-using-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining PDFs on a Mac</title>
		<link>http://mri.brechmos.org/2009/05/combining-pdfs-on-a-mac/</link>
		<comments>http://mri.brechmos.org/2009/05/combining-pdfs-on-a-mac/#comments</comments>
		<pubDate>Tue, 12 May 2009 02:43:16 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=163</guid>
		<description><![CDATA[This is from MacOSX Hints (here) python ‘/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py’ -o …]]></description>
			<content:encoded><![CDATA[<p>This is from MacOSX Hints (<a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.macosxhints.com');" href="http://www.macosxhints.com/article.php?story=20060327192826493&amp;lsrc=osxh">here</a>)</p>
<p>python ‘/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py’ -o    …</p>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2009/05/combining-pdfs-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GnuPG Signing of Files</title>
		<link>http://mri.brechmos.org/2009/05/gnupg-signing-of-files/</link>
		<comments>http://mri.brechmos.org/2009/05/gnupg-signing-of-files/#comments</comments>
		<pubDate>Tue, 12 May 2009 02:42:10 +0000</pubDate>
		<dc:creator>craig</dc:creator>
				<category><![CDATA[Computing]]></category>

		<guid isPermaLink="false">http://mri.brechmos.org/?p=161</guid>
		<description><![CDATA[To sign a file: $ gpg --detach-sign -u &#60;email address&#62; --armor &#60;file&#62; To verify a file: $ gpg --verify &#60;file&#62;.asc]]></description>
			<content:encoded><![CDATA[<p>To sign a file:</p>
<pre>$ gpg --detach-sign -u &lt;email address&gt; --armor &lt;file&gt;</pre>
<p>To verify a file:</p>
<pre>$ gpg --verify &lt;file&gt;.asc</pre>
]]></content:encoded>
			<wfw:commentRss>http://mri.brechmos.org/2009/05/gnupg-signing-of-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

