User:Jadrian Miles: Difference between revisions

From VrlWiki
Jump to navigation Jump to search
Jadrian Miles (talk | contribs)
Jadrian Miles (talk | contribs)
Nifty code snippets: PDF cropping
 
(3 intermediate revisions by the same user not shown)
Line 15: Line 15:
** [[/End-of-PhD cleanup taks]]
** [[/End-of-PhD cleanup taks]]
* '''Project Notes'''
* '''Project Notes'''
** [[/Voxelizer and blockhead]]
** [[/Chi-squared clustering]]
** [[/Chi-squared clustering]]
** [[/Triangle toy problem]]
** [[/Triangle toy problem]]
Line 48: Line 47:
* Update a directory with stuff that exists in a CVS repository but not in the directory:
* Update a directory with stuff that exists in a CVS repository but not in the directory:
*;<pre>cvs update -d</pre>
*;<pre>cvs update -d</pre>
* Concatenate PDFs (more at [http://web.archive.org/web/20090223000710/http://ansuz.sooke.bc.ca/software/pdf-append.php? the original source]; even more [http://nixtricks.wordpress.com/2009/09/01/cli-combine-or-remove-pages-from-a-pdf-document-using-ghostscript/ elsewhere])
* Concatenate PDFs (more at [http://web.archive.org/web/20090223000710/http://ansuz.sooke.bc.ca/software/pdf-append.php? the original source]; even more [http://nixtricks.wordpress.com/2009/09/01/cli-combine-or-remove-pages-from-a-pdf-document-using-ghostscript/ elsewhere], as well as [http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf how to extract ranges of pages])
*;<pre>gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf ...</pre>
*;<pre>gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf ...</pre>
* Recache TeX search paths:
* Crop PDF (more at [http://stackoverflow.com/questions/10417151/pdf-remove-white-margins/10418720#10418720 StackOverflow]:
*;<pre>sudo mktexlsr</pre>
<div style="margin-left: 1.5em">
First, figure out the size of the bounding box:
<pre> gs -q -dBATCH -dNOPAUSE -sDEVICE=bbox orig.pdf 2>&1 | grep -v HiRes
%%BoundingBox: 134 158 471 715
...</pre>
The resulting bounding box is in the form <code>B_x B_y T_x T_y</code>, where B and T are the coordinates of the bottom and top corners, respectively, measured in points.
The bounding box lies on a page of a certain size.  One point is 1/72", so letter size is 612x792pt.
In this case, we'd like to leave a 10pt margin on all sides.  That means offsetting the page down and left by 124x148pts, and then cropping to a page size of (471-134)+20=357pts wide and (715-158)+20=577pts tall. The command is:
<pre> gs -o cropped.pdf -sDEVICE=pdfwrite -g3570x5770 -c "<</PageOffset [-124 -148]>> setpagedevice" -f orig.pdf</pre>
Note that the argument to <code>-g</code> is in ''tenths'' of a point.
</div>
* Recache TeX search paths: <pre>sudo mktexlsr</pre>
* Perceptually uniform random coloring in Matlab
* Perceptually uniform random coloring in Matlab
<pre style="margin-left:1.5em">
<pre style="margin-left:1.5em">
Line 58: Line 68:
</pre>
</pre>
* Recursively download a website using wget (see [http://www.editcorp.com/Personal/Lars_Appel/wget/wget_2.html#SEC11 the man page] for more) <pre>wget -r -np -nH http://www.site.com/subdir</pre>
* Recursively download a website using wget (see [http://www.editcorp.com/Personal/Lars_Appel/wget/wget_2.html#SEC11 the man page] for more) <pre>wget -r -np -nH http://www.site.com/subdir</pre>
* Recursively download a remote directory via SSH, preserving modification times (note the trailing slash on the remote directory!): <pre>rsync -ra -e ssh <server>:<dir>/ <local_path></pre>


==== Bookmarks ====
==== Bookmarks ====

Latest revision as of 19:22, 27 January 2014

I started my PhD in CS at Brown in Fall 2006. I work on data processing, measurement, and model reconstruction from diffusion MRI of the brain.

You can find me elsewhere online:

There are a number of directories related to me on the CS filesystem, all of which are linked from file:///map/gfx0/users/jadrian

Personal Documents

Draft pages / notes

Nifty code snippets

  • Generate a random filename from the command line:
    set tmpfile=/tmp/`head -q -c 8 /proc/sys/kernel/random/uuid`
  • Convert stdin to lowercase on stdout:
    tr '[A-Z]' '[a-z]'
  • Rename files into consecutive zero-padded integers in bash:
    let i=0; for f in *.JPG; do mv $f `printf "%04d" $i`.jpg; let i++; done
  • Test for host availability in tcsh (for loop demo; see here for bash example):
foreach h ( `cat hostlist` )
  ssh $h uname -n
end

First, figure out the size of the bounding box:

 gs -q -dBATCH -dNOPAUSE -sDEVICE=bbox orig.pdf 2>&1 | grep -v HiRes
%%BoundingBox: 134 158 471 715
...

The resulting bounding box is in the form B_x B_y T_x T_y, where B and T are the coordinates of the bottom and top corners, respectively, measured in points. The bounding box lies on a page of a certain size. One point is 1/72", so letter size is 612x792pt. In this case, we'd like to leave a 10pt margin on all sides. That means offsetting the page down and left by 124x148pts, and then cropping to a page size of (471-134)+20=357pts wide and (715-158)+20=577pts tall. The command is:

 gs -o cropped.pdf -sDEVICE=pdfwrite -g3570x5770 -c "<</PageOffset [-124 -148]>> setpagedevice" -f orig.pdf

Note that the argument to -g is in tenths of a point.

  • Recache TeX search paths:
    sudo mktexlsr
  • Perceptually uniform random coloring in Matlab
C = makecform('lab2srgb');
plot3(X,Y,Z,'Color', applycform([50+rand*50, -100+rand*200, -100+rand*200], C));
  • Recursively download a website using wget (see the man page for more)
    wget -r -np -nH http://www.site.com/subdir
  • Recursively download a remote directory via SSH, preserving modification times (note the trailing slash on the remote directory!):
    rsync -ra -e ssh <server>:<dir>/ <local_path>

Bookmarks

Tutorials

Miscellaneous notes

  • High b sensitizes to short length scale (Assaf & Cohen 1998, 2000).
  • The cingulum bundle looks like a long, skinny tube (that wraps around the top and back of the CC) in a gross segmentation, and fibers run along the long axis of this tube for most of this length. Their projections into the GM, though, are actually along the side of the tube, on mid-sagittal gyri. This is a really weird shape when it comes to inferring fiber paths from the bundle shape, so it should be a smoke test for any proposed system.
  • Sculpture might be a good choice for the second outside minor course. 3D reasoning, malleable shapes...