Monday, April 14, 2014

Retreiving all your iPhone Files (including voice mail)


So I wanted to save some important voicemails from my iPhone along with some other files to my Windows 7 PC. As you may know you can only get a few file types using iTunes. I typically use iTools (http://www.itools.cn/multi_lang_pc_download.htm) most of the time. It's free and is nice program. However, it didn't seem to have the ability to extract voice mail files. Thus starting my search for a different tool.

There are several tools available that seemed to be able to do it, but they weren't free or even cheap for what I needed. I found that if I used iTunes (v11.1) to backup my phone that all the files are saved to the directory C:\Users\YourUserName\AppData\Roaming\Apple Computer\MobileSync\Backup\. Within that folder is a large number of files without extensions or even names that make any sense. I tried adding a .mp4 extension to a few of the largest files. I was able to play them in a media player. So...the files seem to be there, but without extension.

Folder with files without extenstions.




















Problem: How do identify the file types of missing file extensions?

I had more that 3,000 files and I wasn't about to try renaming each file until I found the voice mail files I wanted. Hmmm....maybe paying for the other software tools is sounding like the better option. Not so fast...I found a command line tool called  TrID that can identify unknown files or files without extensions based on their binary signatures. It includes a feature to rename those files based on the identified extensions. Sounds promising.

Here's how to put it all together.


  1. Backup your iPhone with iTunes.
  2. Locate your backup directory within: C:\Users\YourUserName\AppData\Roaming\Apple Computer\MobileSync\Backup\
  3. Download TrID and the TrID definitions located at the bottom of the product page.
  4. Make a copy of your iTunes backup folder from above just in case. Not sure if this is necessary, but didn't want to mess up the original files
  5. Extract the TrID and TrID definitions file into the same directory. I extracted them to my phone backup.
  6. Open a command window and cd to your backup directory. There you execute the command "trid * -ce" to identify and rename all files.


Here's the final results. All files (except a few) now have file extensions including the voice mail files (*.amr).




Saturday, November 2, 2013

ECG Viewer

{Under Construction}

 ECG Viewer is a simple MATLAB GUI for reviewing, processing, and annotating electrocardiogram
(ECG) data files. ECG Viewer offers an annotation database, ECG filtering, beat detection using
template matching, and inter-beat interval (IBI or RR) filtering. Program was created using
MATLAB 2008b.

Download ECGViewer from Sourceforge.net here: http://sourceforge.net/projects/ecgviewer/

Shortcut Keys
  Use the up and down arrow keys to jump to the next/previous IBI outlier.
  Use the left and right arrow keys to jump to the next/previous detection.
  You must click on somewhere on the GUI before using the arrow keys.
  Double click on annotations to see more details.
  Double click on file name to load the ECG.
Other
  Use the arrow buttons next to the “preview” button to automatically load the
previous/next ECG data file
  “Start Time” and “Length” options located above the list of ECG files are used to limit
the amount of data loaded from the ECG file. “Start time” represents the beginning
time. “Length” represents the length of data to load in reference to the starting time.
Start time + length = end time.
fdf

ECG Data
As of version 1.1.13, ECG Viewer can read MATLAB binary files (.mat) and ASCII text files (.txt). If using MATLAB binary files (.mat), the software will load the data and then try to find a variable named “ecg” or “ECG”. If not found, the software will use the first variable loaded from the .mat file.
The ECG data is expected to have one or two columns. If one column is used, this column must represent ECG amplitude in arbitrary units. If two columns are used, the first column represents time in units of seconds. The second column represents ECG amplitude in arbitrary units.
ECG Filtering
Two type of ECG filtering are currently available in ECG Viewer.
1. Fast Smooth – Filters ECG base using two moving average filters. User can specify the number of passes from 1x-3x. Low-pass filter (LPF) setting can be adjusted by changing the LPF span. Larger LPF spans eliminate a broader range of high frequency components. High-pass filter (HPF) setting can be adjusted by changing the HPF span. Smaller HPF spans eliminate a broader range of low frequency components. (this need rewording)
2. Wavelet – This filtering method used MATLAB’s wavelet toolbox. The ECG is first decomposition using wavelet decomposition. The user defines the wavelet family to use and the sub-bands (frequency bands) to remove. 
Beat Detection
Beat detection is accomplished using a correlation-based template matching algorithm.  A sliding window is passed across the ECG signal, and a correlation coefficient, rxy, is computed between the template and the ECG contained within each window of equal length. Here the correlation coefficient represents the similarity between template and ECG segment. This process produces a new data series containing correlation coefficients rxy. The correlation coefficient between two N length segments of x and y is computed using the following equation:
If the correlation, rxy, between template and ECG segment exceed a defined upper threshold value a detection flag is set to high (Figure.1-c). This flag is held in a high state until rxy drops below a defined lower threshold (Figure.1-d). A beat is set as the largest rxy peak between any high and low detection flag events (Figure.1-b).  Detected beats are marked with green circles. This double threshold method helps eliminate multiple peak detections within a close vicinity of one another.
Computational speed of template matching can be improved using the following three methods (see the function detectBeats() within ecgViewer.m and see matchTemplate.m ):
1. Skip Indexing - This method involves reducing the number of times the sliding window translates across the ECG signal. By translating every third ECG sample instead of indexing one sample, 1/3 as many correlation coefficients are computed. Skipped rxy values are replaced using cubic spline interpolation. 
2. Parallelization - This method involves parallelizing a portion of the template matching code for multi-core processor environments.
3. Combination - This method combines both the skip indexing and parallelized methods. 
Skipping samples, parallelizing code, and a combination of the two methods reduce computation time (17.2 s original) by approximately 64% (6.2 s), 58% (7.3 s), and 82% (3.16 s) respectively. These data are based on the results of 3 simulations of each technique using an ECG segment of 600,000 samples and a template of 161 samples in length.
Two types of detection methods exist on the ECG Viewer GUI:
1. Template Matching – standard template matching
2. Self  Template – This methods using the defined template file to create a new template base on the current ECG file. The current template is used to detect QRS complexes from the first 60,000 samples of ECG. These detected beats are then averaged together to create a “self template”. This self template is used in beat detection. NOTE: The sample length and template width may need to be modified for your preference.

Figure.1 – QRS detection using template matching. Plots include (a) example template used for QRS detection by template matching, (b) rat ECG with detected QRS complexes, (c) rxy data series and peaks detected using the double threshold technique, and (d) state of the detection flag used in the double threshold technique.

Building a template
ECG Viewer’s template matching marks beats as the center of a matched template. For example, if you make the center of your template correspond with the R-wave peak, then template matching will mark R-waves on your ECG data, etc.
Averaging several QRS templates together may help create a more universal template
IBI Filtering
IBI filtering is used to mark IBI “outliers”. If an outlier is detected based on the user selected criteria, the beat that initiated the IBI and the IBI itself is marked as an outlier on the plots. Outliers are marked by a filled red circle. Although the term filter is used in this section, no change to the original IBI occurs during ectopic interval detection.
Filter Types:
1. percentage filter – marks intervals that change by more than a user defined percentage (often 20%) from the previous interval [55].This method locates any sudden or abrupt IBI changes.
2. standard deviation filter –  marks outliers as being intervals that lie beyond the mean IBI by a user defined value of standard deviations (often 3 SD) [55].
3. median filter –  acts as an impulse rejection filter with threshold to delineate ectopic intervals [50]. The median filter of a random variable x of length N using a threshold of τ is given by 
 
4. above threshold filter – marks any interval lying above the user defined threshold limit as outliers
5. below threshold filter– marks any interval lying below the user defined threshold limit as outliers
6. custom filter – this was a personal filter used to ignore IBI near large spikes in the ECG signal. The first box defines the amplitude limit, and the second box defines the window width. Any IBI within the window width around ECG that has an amplitude above the limit is ignored.
Exporting
Two types of data can be exported using the export button located on the GUI within the export module. 
1. Export ECG – this button exports the currently loaded ECG file. File formats available for ECG exporting include MATLAB binary (.mat), 16-bit binary (.dat), text/ASCII (.txt), and Excel (.xls).
2. Export IBI – this button exports the IBI of the currently loaded ECG file. File formats available for IBI exporting include MATLAB binary (.mat), text/ASCII (.txt), and Excel (.xls).
The option labeled “Export current window only” tells ECG Viewer to only export the ECG or IBI currently displayed in the plots. In other words whatever you see on the screen is what gets exported.
File Annotations and Database
ECG Viewer allows users to annotate files and mark files as being “completed”.
These task can only be completed on the currently loaded ECG file.
Annotation can be created at any time point on the ECG file currently displayed by double clicking on the desired point on the ECG plot.
Annotations can be reviewed by double clicking on an annotation label within the annotation list. This list is located below the list of ECG files.
ECG files can be marked as being “complete” by loading the desired file and right clicking anywhere on the ECG plot.
To remove annotations you must load the Microsoft Access file and do it manually.
Before using the database feature the first time you must create a datasourse in your Windows environment. See http://MATLAB.izmiran.ru/help/toolbox/database/instal12.html#18933. This is only done once.

HRVAS: Heart Rate Variability Analysis Software


{Under Construction}

HRVAS is a heart rate variability (HRV) analysis tool developed using MATLAB. HRVAS can detrend and filter IBI and can perform time domain, frequency domain, time-frequency, Poincare', and nonlinear HRV analysis.

Features:

  • Single GUI
  • Batch processing
  • Time-domain HRV
  • Frequency-Domain HRV
  • Poincare
  • Nonlinear HRV
  • Time-Frequency HRV
  • IBI Preprocessing
  • Export Results to Excel


Download HRVAS from Sourceforge.net here: http://sourceforge.net/projects/hrvas/





















Thursday, August 1, 2013

Hello World

I want to create an blog of my projects and other things that I've learned. It's both for myself to remember and document my projects and, if I'm lucky, it will be useful to someone else. I have several post started an will begin posting them in December.