Thursday, August 29, 2013

Convert powerpoint file to high resolution .tif file in Mac

Powerpoint is a powerful tool for making versatile plots for publication, which can be exported as low resolution figure files. Many journals, however, requires high resolution .tif file for publication. Here is how to convert .pptx or .ppt file (in Powerpoint 2011) to .tif file in Mac OS.


1. Convert .ppt file to pdf file:
a.     File -> “Reduce file size” -> In “picture quality” dropdown box, select “Best for Printing (220ppi)” -> click “OK”
b.     File -> Save As -> In “format” dropdown box, select “PDF” -> In “Options” , enter the largest number possible for width and height -> Click “OK” ->  Click “Save”

      2. Convert .pdf file to .tif file. This can be done in two methods.

2-1 .The first method is open .pdf file in Adobe Acrobat Pro, then
a.     File -> Save As -> in “Format” dropdown box, select “TIFF”
b.     Click “Settings” to the right of “Format”. In the dialog box,
                                               i.     select “LZW” for both “Grayscale” and “Color”,
                                             ii.     select “Color:RGB” in “Colorspace”
                                            iii.      in “Resolution” box, select “300 ppi” or higher.
2-2. The second method needs Photoshop.
c.     File→Open the PDF. You will need to do this one page at a time. Make sure you're importing it at 300ppi, RGB.
d.     Use the Crop Tool (fifth from the top of the toolbar) to select an area close to the borders of your image. Hit Enter to apply the crop.
e.     Layer→Flatten Image
f.      Image→Image Size. Uncheck the Resample Image checkbox. If the Width is over 17.35cm, type 17.35 in the Width box (17.35cm is our maximum allowable width for figures). The Resolution will go up automatically as the Width decreases. If the resolution does not hit 300 when you make the Width 17.35, type 300 in Resolution and as long as Width doesn't go below 8.3cm, everything is fine. Also, the height cannot be more than 23.35. If the Height and Width are within these prescribed limits, no adjustment to your figure size needs to be made.
g.     File→Save As. Save as TIFF, Image Compression set to LZW, Pixel Order set to Interleaved, Byte Order set to IBM PC.


Tuesday, August 6, 2013

Latex template

This webpage presents a good collection of latex template, including a variety of writing styles:
http://www.latextemplates.com/

Monday, August 5, 2013

Matlab gcc compiler installation for Mac Mountain Lion

Today I was trying to mex functions in matlab but an error occurs: "gcc-4.2: command not found". Xcode 4.2 or later does not have gcc-4.2 although it is required for matlab/python programming, so users have to install the compiler manually. I found a useful discussion regarding this issue

http://www.mathworks.com/support/solutions/en/data/1-FR6LXJ/

Allow me to copy and paste the solution here:
LAST UPDATED: 2013/02/04
If you have downloaded patches from this solution before this date, and still experiencing issues, please re-download and reapply the patches below, as they have been updated with additional fixes. Note that the "Date Last Modified" value shown at the top of this solution may be different, due to minor edits that do not affect the patches.

Update History:
2013/02/04: added Xcode 4.6 support.
2012/10/17: added Xcode 4.5 support and Simulink patch link.
2012/09/13: added R2012b support.
2012/09/05: added patch for Mac OS X 8.

*** Scope of this solution ***
This solution concerns the Mac platform only, with the following software versions only:
MATLAB versions:
- R2011a
- R2011b
- R2012a
- R2012b

AND

Xcode versions:
- 4.6
- 4.5
- 4.4
- 4.3
- 4.2
- 4.1

AND

Mac OS X versions:
10.6 (Snow Leopard), for Xcode versions 4.1 and 4.2 only
10.7 (Lion), for Xcode versions 4.1 to 4.6 only
10.8 (Mountain Lion), for Xcode versions 4.4 to 4.6 only

Do not apply the steps described in this solution to any other combination of MathWorks and Apple software.

For MATLAB releases before R2011a, use an older compatible version of Xcode as documented in the page “Supported and Compatible Compilers - Previous Releases”:

http://www.mathworks.com/support/sysreq/previous_releases.html

---For Simulink Users---
For Simulink users utilizing Accelerator, Rapid Accelerator and Code Generation functionality, refer to the solution 1-HDKZEH (linked below) to download additional Simulink patches AFTER applying the MATLAB patches below.


*** Description of the issue ***
If you use one of the above listed MATLAB releases with one of the above Xcode releases, you may see an error message like the following when using MEX, or attempting to use any other feature reliant on the presence of a C/C++ compiler:

1.
/Applications/MATLAB_R2011b.app/bin/mex: line 305: gcc-4.2: command not found
This is happening because MATLAB is expecting GCC 4.2 to be present. This compiler was distributed with Xcode 4.0 and 4.1, but is no longer supplied as of Xcode 4.2.

However, Xcode 4.2 and later include a similar compiler (GCC 4.2 front-end to LLVM) that MATLAB can be instructed to use instead. Applying the patch attached to this solution will instruct MATLAB to use the compiler supplied with Xcode 4.2 or later.

2.
/Applications/MATLAB_R2012a.app/extern/include/matrix.h:852:20: error: stdlib.h: No such file or directory
This is happening because the SDKROOT directory for Xcode 4.2 and earlier are:
/Developer/SDKs/MacOSX10.7.sdk/but Apple changed this directory to
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/in its Xcode versions 4.3 and higher. Applying the patch sets the correct SDK root depending on the Xcode compiler present on the computer.

You may need administrative permissions on your Mac to complete these steps.


*** Before applying the patch ***
1. Ensure your Xcode is installed in the default directory and has the "Xcode.app" default name. For Xcode 4.3 and later, this is:
/Applications/Xcode.appFor Xcode 4.1 and 4.2, this is:
/Developer/Applications/Xcode.app
2. If using Xcode 4.3 and later, ensure that the Xcode "Command Line Tools" are installed. To do this:

Since Xcode 4.3, the command line tools needed by MATLAB must be downloaded after the installation of Xcode itself. This does not happen by default. In Xcode, go to Preferences -> Downloads -> Components, and check “Check for and install updates automatically” and install the “Command Line Tools”.

3. After installing the "Command Line Tools" above, confirm that the following command (in the MATLAB command window)
!xcodebuild -versionreturns the proper version of your Xcode. If this command does not return the version of Xcode, your Xcode was either installed incorrectly or installed in a non-default location.

4. If you have multiple versions of Xcode, make certain that the version you want to use for MATLAB has the default "Xcode.app" name, is in the default installation directory, and that this version has the "Command Line Tools" installed, i.e., the Xcode version must be the same for all three steps above. Note that only one version of "Command Line Tools" can be installed on a machine at any given time (installing it from different versions will overwrite the previous version).


*** To apply the patch ***
1. Download the appropriate patch for your MAC OS X version, attached to this Solution:

optsPatch_MACOSX6.patch
optsPatch_MACOSX7.patch
optsPatch_MACOSX8.patch

These instructions assume you download it to the default location Safari uses, namely the “Downloads” folder of your home folder.

2. Start MATLAB, if it is not already running.

3. In the MATLAB Command Window, type:
>> cd(matlabroot)
>> !unzip -o ~/Downloads/optsPatch_MACOSX7.patch

or

>> cd(matlabroot)
>> !unzip -o ~/Downloads/optsPatch_MACOSX6.patch

or

>> cd(matlabroot)
>> !unzip -o ~/Downloads/optsPatch_MACOSX8.patch

depending on the patch downloaded. Administrator privileges may be required for this step.

4. Set your compiler configuration by running:
>> mex -setup
5. If you use MATLAB Compiler, run the command:
>> mbuild -setup
MEX, MATLAB Compiler, and other MathWorks products should now be configured to use the compiler provided with Xcode 4.2 or later.


*** Troubleshooting ***
If, after installing the patch, you get an error such as this:
/Applications/MATLAB_R2011b.app/bin/mex: line 305: llvm-gcc-4.2: command not foundyou should check to make sure that a supported version of Xcode is installed on your machine. Launch Xcode, either from the Dock or from your Applications folder.

If Xcode launches, click "About Xcode" to make sure the version is within 4.1 to 4.6:
Can I use Xcode 4.2 to 4.6 as my C or C++ compiler in MATLAB? (Updated: 2013/02/04)

If you cannot find Xcode, cannot launch it, or the version is not Xcode 4.1, 4.2, 4.3, 4.4, 4.5 or 4.6 you should reinstall Xcode and repeat steps 4 and 5 above.

If Xcode launches, but issues remain, confirm that all the prerequisites listed in the "Before applying the patch" section above is followed. 

If after the above steps, Xcode is installed correctly and works as intended, but it still cannot be used in MATLAB, try applying an older version of the patch below:

Xcode4_OLD.patch
(For MAC OS X 6, 7, or 8 with Xcode 4.2 or higher)

WARNING: This patch does not set the SDKROOT property and may fail depending on your code to be compiled. Only try this patch as a last resort, if the other OS specific patch fails and Xcode is tested to be working properly outside of MATLAB.

*** Note *** 
The patches attached to this solution can be used with any combination of MATLAB release / Xcode version as described in the scope of this solution (see above).