# SWHarden.com

The personal website of Scott W Harden

# Run Ubuntu Live CD From a USB Drive

I accidentally nuked my laptop’s 80G hard drive this morning (D’OH!) while shuffling around partitions. Supposedly there’s a valid windows (XP) installation on there still that’s about 20G. I’d love to repair it so I can use it today while I’m in the confocal room, but I don’t have an Ubuntu CD, Windows CD, or any CD for that matter! I looked around, but I guess blank CD-Rs aren’t something that’s standard in molecular biology laboratories. Anyhow, I wanted to install the new Ubuntu 8.10 Linux distribution, and I’ve downloaded the ISO, but since I can’t find a CD to burn it to I decided to try booting from a USB drive (something I’ve never done before). I found an AWESOME program which specialized in putting ISO files onto bootable USB drives. It’s called UNetBootin and it’s free (of course), runs on Linux or Windows, and has some built-in options for various linux distributions. I can repair my PC now! Yay!

# Linear Data Smoothing in Python

``` obsolete``` ``` python```

⚠️ SEE UPDATED POST: Signal Filtering in Python

``````def smoothListGaussian(list, degree=5):
window = degree*2-1
weight = numpy.array([1.0]*window)
weightGauss = []
for i in range(window):
i = i-degree+1
frac = i/float(window)
gauss = 1/(numpy.exp((4*(frac))**2))
weightGauss.append(gauss)
weight = numpy.array(weightGauss)*weight
smoothed = [0.0]*(len(list)-window)
for i in range(len(smoothed)):
smoothed[i] = sum(numpy.array(list[i:i+window])*weight)/sum(weight)
return smoothed
``````

Provide a list and it will return a smoother version of the data. The Gaussian smoothing function I wrote is leagues better than a moving window average method, for reasons that are obvious when viewing the chart below. Surprisingly, the moving triangle method appears to be very similar to the Gaussian function at low degrees of spread. However, for large numbers of data points, the Gaussian function should perform better.

``````import pylab
import numpy

def smoothList(list, strippedXs=False, degree=10):
if strippedXs == True:
return Xs[0:-(len(list)-(len(list)-degree+1))]
smoothed = [0]*(len(list)-degree+1)
for i in range(len(smoothed)):
smoothed[i] = sum(list[i:i+degree])/float(degree)
return smoothed

def smoothListTriangle(list, strippedXs=False, degree=5):
weight = []
window = degree*2-1
smoothed = [0.0]*(len(list)-window)
for x in range(1, 2*degree):
weight.append(degree-abs(degree-x))
w = numpy.array(weight)
for i in range(len(smoothed)):
smoothed[i] = sum(numpy.array(list[i:i+window])*w)/float(sum(w))
return smoothed

def smoothListGaussian(list, strippedXs=False, degree=5):
window = degree*2-1
weight = numpy.array([1.0]*window)
weightGauss = []
for i in range(window):
i = i-degree+1
frac = i/float(window)
gauss = 1/(numpy.exp((4*(frac))**2))
weightGauss.append(gauss)
weight = numpy.array(weightGauss)*weight
smoothed = [0.0]*(len(list)-window)
for i in range(len(smoothed)):
smoothed[i] = sum(numpy.array(list[i:i+window])*weight)/sum(weight)
return smoothed

### DUMMY DATA ###
data = [0]*30  # 30 "0"s in a row
data[15] = 1  # the middle one is "1"

### PLOT DIFFERENT SMOOTHING FUNCTIONS ###
pylab.figure(figsize=(550/80, 700/80))
pylab.suptitle('1D Data Smoothing', fontsize=16)
pylab.subplot(4, 1, 1)
p1 = pylab.plot(data, ".k")
p1 = pylab.plot(data, "-k")
a = pylab.axis()
pylab.axis([a[0], a[1], -.1, 1.1])
pylab.text(2, .8, "raw data", fontsize=14)
pylab.subplot(4, 1, 2)
p1 = pylab.plot(smoothList(data), ".k")
p1 = pylab.plot(smoothList(data), "-k")
a = pylab.axis()
pylab.axis([a[0], a[1], -.1, .4])
pylab.text(2, .3, "moving window average", fontsize=14)
pylab.subplot(4, 1, 3)
p1 = pylab.plot(smoothListTriangle(data), ".k")
p1 = pylab.plot(smoothListTriangle(data), "-k")
pylab.axis([a[0], a[1], -.1, .4])
pylab.text(2, .3, "moving triangle", fontsize=14)
pylab.subplot(4, 1, 4)
p1 = pylab.plot(smoothListGaussian(data), ".k")
p1 = pylab.plot(smoothListGaussian(data), "-k")
pylab.axis([a[0], a[1], -.1, .4])
pylab.text(2, .3, "moving gaussian", fontsize=14)
# pylab.show()
pylab.savefig("smooth.png", dpi=80)
``````

This data needs smoothing. Below is a visual representation of the differences in the methods of smoothing.

The degree of window coverage for the moving window average, moving triangle, and Gaussian functions are 10, 5, and 5 respectively. Also note that (due to the handling of the “degree” variable between the different functions) the actual number of data points assessed in these three functions are 10, 9, and 9 respectively. The degree for the last two functions represents “spread” from each point, whereas the first one represents the total number of points to be averaged for the moving average.

# Charge a Razor phone from a PC USB port

I’m posting this because I wanted to charge my Motorola Razor v3 Phone from a USB port on a PC using one of those standard miniUSB cables, and you wouldn’t believe how hard it was for me to find out how! I didn’t want to do any special software imports or exports or communication with the phone - I just wanted to get my battery charged before it died! It was surprisingly hard to find the software to send power to the USB port for windows. These were the two solutions I came across.

Solution1: Install DriverTool.exe (which will add some drivers) and allow power to be sent to the phone when it’s plugged in.

Solution2: Simply use UBUNTU (booted from the LiveCD or an installation) and plug in the cord. It automatically sends power to the phone, no drivers needed!

# Custom MiniDisc Labels with Photoshop

``` obsolete```

Great looking MiniDisc labels can be made at home! In this post I’ll show you how I created the nice MiniDisc labels shown on this page. Links to the Photoshop template are at the bottom of the page so you can make your own labels too.

## MiniDisc Label Dimensions

Getting these labels to properly fit your MiniDisc can be harder than it seems. Your best bet is to make a practice sheet where the shapes are solid colors. Print it, cut it out, hold it up, and see if any of the sizes need adjusting. It might take a few tries, so don’t be afraid to use up a few sheets of paper!

Measurement Width Height
Front `1.407` inches `2.077` inches
Spine `2.360` inches `0.113` inches

## MiniDisc Label Templates for Photoshop

If you have Photoshop you can download one of the blank MiniDisc label templates I created.

## Printing MiniDisc Labels

The labels I’ve been making lately have been printed on Avery’s White Full Sheet Labels #8165. I got a pack of 25 of them at OfficeMax for \$9.99 (which equates to a little less than 40 cents a sheet). If you’re interested in purchasing them, I recommend this brand and know I’ll be buying more personally (that is, when I run out of 25 sheets (which is about 150 labels worth of paper)). The best printing settings for this type of paper are those that will place a little more ink on the page than normal. With my HP DeskJet 932C, I’ve been getting good results by printing with the settings normally used for textured greeting cards.

## Cutting MiniDisc Labels

Cutting your labels well is the crucial step for making great labels. This is your make or break moment! It’s incredibly important that you relax and take your time when you cut these labels. The right tools help a lot too. While it is possible to cut your labels with scissors, I strongly recommend you use a double blade slicer. The one I’m using is made for photos. A razor blade is helpful when it comes to separating the sticky paper from the wax coated base sheet.

Begin by using scissors to clip each label set out of the paper. Leave around half an inch around the actual image so you can touch the paper to avoid smearing the fresh ink. Look closely at the image and locate the crosshairs at the corners. If you focus on slicing the image just inside the crosshairs you’ll get far better results than if you try to cut on the edge of the colored portion. It’s a lot easier to line up a blade with a thin line than it is with a contrasting edge. When you’re ready, hold your paper firmly and slice it. Try your best to get clean slices, and don’t be afraid to shave off a small portion of the colored area to ensure that you don’t leave any white on the edges.

Notice how I cut a 0.5mm border around the edge of the image in preparation for my final trimming. This greatly improves the precision you get when making your final slices.

Pay extra attention when you cut the corner at the top left of the MiniDisc label. This little cut plays a large role in what the finished product will look like. Since it’s the only irregularity in the shape of the label, the eye is naturally drawn to it. The angle needs to be as close to 45º as you can get it. That little slice is a lot smaller than you think, so when you cut it don’t take too much off! The size of the slice in the edge on the recessed region of your minidisk is about twice the size that your slice should be, since your paper will border slightly inside the recessed area. This step is really, really important. Notice how I line up the edge of my label with the corners of the squares on my slicer to ensure I get a clean, even, and level 45º cut on the corner! Hitomi looks scared in this picture.

Once everything is cut, and before you remove the backing, hold up the labels to the MiniDisc you’ll be putting them on to make sure everything is perfect. The labels should fit cleanly, with a small amount of room between the label and the edge of the recessed region. If you’re dissatisfied with the color of MiniDisc you had in mind while designing this label, you still have a chance to make a last minute change! I’m second guessing my own color choice here, as the blue seems to go better with the orange now that I look at the printed label.

## Preparing the Labels

Perhaps the most frustrating part of your project is separating the sticky paper from the wax coated paper backing. Some label paper has convenient little creased pre-sliced edges on the back to help you separate the two, however more often than not the stupid little things are never in the right place so you’re left with really cool images that can be ruined in a second by clumsy separation of the paper layers. I found that a sharp razor blade helps a lot with this step. If you carefully wedge the tip of your razor between the two layers, you can separate them enough that they can be split by hand.

In the photo below notice how I’m using that little corner slice to my advantage. The corner method works wonders with the spine as well. Just be careful that you don’t cut it!

### Applying the Labels

Much like slicing your labels, this next step is a highly visible one that makes a big impact on what your final project will look like. I like to apply the big face label first because it’s a little easier. It’s really easy to stick a label on crooked if you’re not careful, so put extra care into proper alignment. I found I get best results when I use one finger to line up and stick the top right corner of the label to the disc first, then slide a finger down to the bottom right corner, then brush to the left securing the rest. If you line up two corners (preferably ones far apart) you know you’ll get a straight and even application.

When applying the spine, attach the leftmost edge of it to the correct place on the edge of the MiniDisc and hold it there with your thumb. Since it’s such a narrow strip, a small portion of the sticky paper touching the plastic won’t hold too firmly, so you can move it around until it’s level to your liking. Once you’re confident it’s level, go ahead and press the other end down (gently) and rub your finger (lightly) from left to right to smooth out the stick. Next, to be sure this spine is stuck on firmly, put some pressure on it with something that won’t smear it (like cloth, your shirt, or perhaps even another sheet of paper if you’re careful). When done correctly, the spine labels can make your MiniDisc look awesome!