Sometimes I have to put text on a path

Friday, March 27, 2015

Three Terminal Commands to get you started (mac apple; linux; Unix)

If you’re running Mac OS X, or your favourite flavour Linux, you’re all set. Just fire up the terminal, and keep going. 

there’s a good change you’ll want to see the contents of a file from the terminal sooner or later. There’s a few commands that will do this for you. First is cat; cat is short for “concatenate”, and this command does more than output file contents; however, that’s what we’ll look at here. It’s as simple as passing the command a file:
However, if the file is large, the contents will all scroll past you and you’ll be left at the bottom. Granted, you can scroll back up, but that’s lame. How about using less?
Less is a much better way to inspect large files on the command line. You’ll get a screen-full of text at a time, but no more. You can move a line up or a line down with the k and j respectively, and move a window up or down with b and f. You can search for a pattern by typing /pattern. When you’re done, hit q to exit the less viewer.
Most of the commands you’ll use in a bash shell are pretty flexible, and have a lot of hidden talents. If you suspect a command might do what you want, or you just want to see some general instruction on using a command, it’s time to hit the manuals, or man pages, as they’re called. Just type man followed by the command you’re curious about.
You’ll notice that the man pages are opened in less.

Thursday, March 26, 2015

Some clients SSH for mac OS, Apple, macintosh OSX, Cross-platform

The following clients are recommended for interoperating with OpenSSH from Mac OS machines. Note that Mac OS X includes OpenSSH by default (application: terminal; only command line =no GUI).
  • http://portingteam.com/index.php/files/file/7089-winscp/
    Download:
  • WinSCP is an open source free SFTP client, SCP client, FTPS client and FTP client for Windows. Its main function is file transfer between a local and a remote computer. Beyond this, WinSCP offers scripting and basic file manager functionality. Like Cyberduck, or Filezilla, but more powerful! 

Remark: You can use winscp to connect to mac machine, but after you enable ssh on mac (System Preferences -> Sharing -> Check Remote Login).

---------------------


One of the best GUI application for SSH (and everything else you can do on the command line) is iTerm 2. https://code.google.com/p/iterm2/ While the original iTerm had a tabbed interface before Terminal did, iTerm 2 again eclipses Terminal by adding:
  • Support for 256 colors (you'll never go back to 16 colors after using 256)
  • Split panes (the sort of thing you can do in GNU screen or tmux, but at the level of the terminal emulator rather than in a program running on the server)
  • Special provision for integrating with tmux (an alternative to GNU screen, and which most people regard as better & faster than screen)
  • Terminal-level auto-completion (I don't use this feature so I can't detail how it has advantages over shell-level autocompletion: especially if you use the fish shell or zsh, then it may not be better)
  • Growl support
  • an Exposé-like view of your tabs
  • a full-screen view (and you can choose from either its own or OS X's built-in full-screen mode; I greatly prefer iTerm's own full-screen mode, since it doesn't force you to move to a new 'Space', thus allowing Command-Tab to still work properly)
  • paste history (a good complement to the shells' command histories)
  • Search
  • Instant Replay
---------------------
ZOC • SSH/Telnet Client and Terminal Emulator for Mac OS X and Windows
http://www.emtec.com/zoc/
not free
---------------------


  • NiftyTelnet 1.1 SSH is an SSH1-only implementation which comes with a scp-style program. Written by Jonas Wallden."NiftyTelnet 1.1 SSH r3 is an enhanced version of Chris Newman's NiftyTelnet 1.1 application which adds support for encrypted terminal sessions using the SSH (Secure Shell) protocol. Please read the included Readme file before distributing this version."
  • MacSSH is an SSH2-only implementation."MacSSH is a modified version of BetterTelnet with SSH2 support. [...] The only SSH2 client for Mac OS that I could find is a commercial product thats costs more than $100, and it crashes my Mac when closing a session... Since it's best to do things by oneself, here's MacSSH."
  • Fugu is an implementation of SFTP and SCP for Mac OS X."Fugu SSH is a Mac OS X graphical frontend to OpenSSH's Secure File Transfer application (SFTP). Fugu allows you to take advantage of SFTP's security without having to sacrifice the ease of use found in a GUI. Fugu also includes support for SCP files transfers, and the ability to create secure tunnels through SSH."
---------------------------------------------
 For example,WinSCP defaults to the SFTP protocol. Even when operating in SCP mode, clients like WinSCP are typically not pure SCP clients, as they must use other means to implement the additional functionality (like the ls command). This in turn brings platform-dependency problems.
---------------------------------------------
Cross-platform:


  •  FireFtp: It's a plug-in for Firefox (that means it's cross-platform). But FireFTP is an FTP client, not an SCP/SSH client.
  • FireSSH is a free, cross-platform SSH terminal client for Mozilla Firefox. Written entirely in Javascript!
  • Secure Shell is an xterm-compatible terminal emulator and stand-alone ssh client for Chrome. It uses Native-Client to connect directly to ssh servers without the need for external proxies.

  • http://www.mucommander.com/;  cross-platform file manager with a dual-pane interface. It runs on any operating system with Java support
------------------------------------------------------
Moreover you can always transfer your files using a terminal. For example using the following command will transfer a file from your mac to a remote server using the scp command: 

Code:

scp -P portnum -i path/to/keyfile path/to/file_you_are_uploading user@server:path/on/server


-P portnum is the port number of the remote server. If your using port 22 then you don't need to specify a port here. But if you are using a port number other that 22, then place it behind the -P 

-i path/to/keyfile is your private key file. I personally don't use passwords when using ssh/scp instead I use private keys. If you use passwords then dont use the -i statement 


---------------------------------------------

http://www.openssh.com/macos.html

PS: OpenSSH is a FREE version of the SSH connectivity tools that technical users of the Internet rely on. Users of telnet, rlogin, and ftp may not realize that their password is transmitted across the Internet unencrypted, but it is. OpenSSH encrypts all traffic (including passwords) to effectively eliminate eavesdropping, connection hijacking, and other attacks. Additionally, OpenSSH provides secure tunneling capabilities and several authentication methods, and supports all SSH protocol versions.

The OpenSSH suite replaces rlogin and telnet with the ssh program, rcp with scp, and ftp with sftp. Also included is sshd (the server side of the package), and the other utilities like ssh-add, ssh-agent, ssh-keysign, ssh-keyscan, ssh-keygen and sftp-server.
OpenSSH is developed by the OpenBSD Project. The software is developed in countries that permit cryptography export and is freely useable and re-useable by everyone under a BSD license.
-----------------------



What is SSH Client?

An SSH client is a software which uses the SSH protocol to connect to a remote computer.
In general SSH protocol can be used for two purposes, file transfers and terminal access.
SSH File Transfers
File transfers are primary focus of WinSCP.
WinSCP supports SFTP (SSH File Transfer Protocol) for secure file transfers. In addition to that it also supports legacy SCP (Secure Copy Protocol).
You can use WinSCP to transfer files both manually and automatically.
SSH Terminal Access
While WinSCP does not focus on terminal access, it has basic support for it.
You can execute remote commands via SSH terminal both manually and automatically.

If you need unrestricted terminal access (and still want to use WinSCP for file transfers), you will find integration with PuTTY SSH client useful. This free Telnet and SSH client for Windows can be also downloaded from our PuTTY download page.

http://winscp.net/eng/docs/free_ssh_client_for_windows



--------------
use some programs (Mathematica e.g.):
ssh servername requires an interactive terminal, which you cannot expect Mathematica to give you. How about doing ssh servername command  ,  which will actually run the command you want, then return. That doesn't require an interactive terminal.

Connexion à des supercomputers (CINES)

Connexion au CINES

A quoi sert SSH ?
SSH permet d’obtenir un shell distant de façon sécurisée contrairement à rsh. Il permet de remédier aux problèmes qui sont :
  • éviter la circulation des mots de passe « en clair » sur le réseau
  • avoir une authentification renforcée des machines, pas seulement basée sur le nom ou l’adresse IP
  • exécuter en toute sécurité des commandes à distance
  • transférer des fichiers de manière sécurisée
  • sécuriser les sessions X11, très vulnérables
il existe SSH :
  • remplacement pour la plus part des R-commandes :
    • ssh remplace rsh, rlogin et telnet,
    • scp remplace rcp,
    • sftp remplace ftp
  • utilise RSA pour une authentification, basée sur l’algorithmique cryptographique à clés publiques entre machines et utilisateurs ;
  • permettre de rediriger tous flux TCP dans le « tunnel » de la session, et en particulier X11 qui peut l’être automatiquement ;
  • chiffrer le tunnel, et au besoin et sur demande, le compresser.
SERVEUR : c’est le logiciel Openssh qui est disponible sur nos machines ; il répond à la fois à la version V1 et V2 du protocole SSH. (voir http://www.openssh.com.)
CLIENT : la machine client, serveur unix ou poste de travail Windows doit disposer d’un client SSH. Il existe de nombreux logiciels (Putty, SSH Secure File Transfer Client…) dont certains sont gratuits (voir openssh).
ssh s’utilise comme les utilitaires unix rsh, rlogin, rcp, etc…
Plusieurs types de connexions sont possibles :
1/ Se connecter d’un site extérieur (France ou étranger) sur le CINES : Si vous avez à vous connecter sur une des machines du CINES (voir liste des machines), à partir d’un site extérieur, par exemple sur la machine leda :
ssh –l user yoda.cines.fr

2/ Copie de fichiers du CINES sur une machine distante Pour copier un fichier de yoda sur une machine distante sur laquelle vous êtes enregistré faut utiliser la commande scp (comme SSH copy). Votre mot de passe sur la machine distante vous sera demandé :
scp fichier.yoda user@:fichier.distant

3/ Copie de fichiers d’une machine distante sur une machine du CINES Pour récupier un fichier d’une machine distante et le copier sur yoda :
scp user@:fichier.distant fichier.yoda

Connexion à la machine

Elle s’effectue en ssh sur yoda.cines.fr
ssh mylogin@yoda.cines.fr

CINES supercomputing, Activity of supercomputer and available softwares

Disponibilité et activité des machines de calcul :

https://reser.cines.fr/dispo/


tous les logiciels installés disposent d’un module. Il est possible d’utiliser la commande module avail pour connaître l’ensemble des modules installés sur la machine.

Comment utiliser un logiciel ? La commande module

La commande module peut être utilisée des manières suivantes :
  • module avail  liste l’ensemble des modules installés sur la machine (par ex. abinit).
  • module load nom_module permet d’ajouter le module à la session en cours (par ex. module load abinit).
  • module show nom_module donne des informations sur le module (version, conflit avec d’autres modules, etc..).
  • module list liste l’ensemble des modules chargés pour la session en cours.
Une fois la commande module load nom_module utilisée, vous pouvez utiliser le logiciel correspondant.

https://www.cines.fr/calcul/faq/

Saturday, August 10, 2013

High resolution figures from Excel (300 dpi): the XL Toolbox, chart export

Scientific journals have explicit requirements for the submission of figures: Most commonly they require high-resolution TIFF files. Using the XL Toolbox, you can produce graphic files with Excel that meet the requirements of the majority of journals. The Toolbox produces these files directly from Excel; third-party illustrator software or virtual printer drivers are not needed.
You can even produce multipanel graphs by arranging charts and drawings on an Excel worksheet and then export them all together using the XL Toolbox. The layout will be preserved, and spreadsheet gridlines will not appear in your graphic file.


http://xltoolbox.sourceforge.net/scientificpublishing/


Thursday, July 25, 2013

Comsol and MRI/CT: the pain of working with complex geometries in Comsol; tutorials for comsol


The pain of working with complex geometries in Comsol!

Some questions :

I am trying to develop a quite simple, but realistic human head 3D model based on MR and CT images and use it as geometry in COMSOL Multiphysics.
My workflow is following: MRI/CT data --> segmentation through Simpleware/Amira/SPM --> STL-file --> COMSOL.
I have googled a lot, tried different settings while exporting to STL and then another different settings while importing in COMSOL, different settings of mesh -- everything is useless, still I have such issues as:1.) Errors in rendering the geometry.2.) Errors while meshing. Here [1] is an example of used model of white matter in STL format -- it seems to be good (MeshLab), what is wrong then, why I cannot create the mesh?3.) Troubles segmenting the CSF.4.) My current experiments involving only one tissue at a time, but which would be the best way to create a geometry consisting of all the subdomains at one time? I mean skin, skull, brain (or WM+GM) and CSF together as different subdomains in geometry.
   ONE answer:
ahhh the pain of working with complex geometries in Comsol.... 
I am working on a very similar problem to yours - but using heart. As Daniel suggested it is much easier to import the mesh into Comsol and then convert it back to a draw object in COmsol. 
1.) Errors in rendering the geometry.This is reallly annoying and time-consuming to resolve. You have to play around with the import options in Comsol. In particular -max angle between boundary elements (70 is a good start) -max angle between neighbouring boundary elements (5-10)-and remove small faces 0.01-0.04by trying out different combinations of these , eventually, you will be able to import the mesh and create a draw object without any rendereing issues.
My current experiments involving only one tissue at a time, ; but which would be the best way to create a geometry consisting of >> all the subdomains at one time?Simpleware allows you to simultaneously mesh a number of masks at the same time. You can then import the mesh, made up of the differnt tissue masks, into comsol. If import is successful Comsol will treat each mask as a seperate subdomain. Because Simpleware takes care of contacts between different masks I found this a much better approach than importing each mask individually into comsol - sometimes u'll have gaps between subdomains which are difficult to find. 
final tip.. make sure your segmented masks are at least 2 voxels wide in any direction (x,y,z,oblique). this helps reeduce the rendering errors u get in Comsol. 
http://comments.gmane.org/gmane.science.analysis.femlab/6587
----

Simpleware should be able to output a COMSOL mesh file, either .mphtxt or .mphbin. You can then import the mesh into COMSOL which should work perfectly (File>Import mesh). You can't make changes to the geometry once it is in COMSOL. STL is not a good CAD or mesh file sharing format at all. You could also get a human head object by requesting this model from your COMSOL sales representitive:
http://www.comsol.com/showroom/gallery/2190/

----

How to use COMSOL batch to solve many files repeatedly without GUI?
http://www.comsol.com/community/forums/3-5a/thread/13315/

--------------------

Some "papers":


Diffusion Processes in Human Brain Using COMSOL Multiphysics, 2006; Cherubini, et al
Facoltà di Ingegneria Università Campus Biomedico di Roma, via Longoni, 83 - 00155
Rome, Italy. International Center for Relativistic Astrophysics - I.C.R.A, University of Rome ``La Sapienza'', I-00185 Rome, Italy.1,2
*Corresponding author: c.cherubini@unicampus.it 
www.comsol.com/papers/1740/.../Cherubini.pdf
----------------
http://www.comsol.com/papers/5499/

Electrical Stimulation of Brain using a realistic 3D Human Head Model: Improvement of Spatial Focality



An MRI slice and the corresponding E-field induced in brain calculated with COMSOL Multiphysics.  By poular vote, this poster won the Best Poster Award at the COMSOL Conference 2008 Boston.
A. Datta, M. Elwassif, and M. Bikson
Department of Biomedical Engineering, The City College of the CUNY, New York, NY, USA
We calculated the spatial distribution of the electric fields induced in the brain during transcranial current stimulation (TCS). The spatial focality obtained using ‘concentric-ring’ configurations is investigated using a realistic MRI derived 3D finite element model of the human head.


Two disc electrode configurations were simulated using COMSOL Multiphysics. The distant-bipolar configuration, which is comparable to commonly used TCS protocols, resulted in diffuse (un-focal) modulation. The reduced concentric-ring results in higher spatial focality at the expense of increased total surface current. Superficial cortical neurons may be thus selectively targeted using a concentric-ring configuration.
---------------
http://www.comsol.com/showroom/gallery/2190/

Absorbed Radiation (SAR) in the Human Brain
Model ID: 2190

Scientists use the SAR (specific absorption rate) to determine the amount of radiation that human tissue absorbs. This measurement is especially important for mobile telephones, which radiate close to the brain. The model studies how a human head absorbs a radiated wave from an antenna and the temperature increase that the absorbed radiation causes.
The increasing use of wireless equipment has also increased the amount of radiation energy to which human bodies are exposed. A common property that measures absorbed energy is the SAR value, (specific absorption rate) to determine the amount of radiation that human tissue absorbs.
The human head geometry is the same geometry (SAM Phantom) provided by IEEE, IEC and CENELEC from their standard specification of SAR value measurements. The original geometry was imported into COMSOL Multiphysics. In addition, the model samples some material parameters with a volumetric interpolation function that estimates the variation of tissue type inside the head.
This model studies how a human head absorbs a radiated wave from an antenna, and the temperature increase that this causes. This model requires the RF Module and the Heat Transfer Module.



Absorbed Radiation (SAR) in the Human Brain



-------------------------------

Tutorial: Working between COMSOL 4.1 and MATLAB 2010b 


Ok, here is what I figured out in order to be able to take a COMSOL model, modify it in MATLAB and then reopen it in COMSOL for further work:

1. Launch COMSOL normally;
2. Launch MATLAB by using "COMSOL 4.1 with MATLAB";

In COMSOL:
- Saving your current COMSOL model into the COMSOL server:
a) File > Export Model to Server...
(Default settings: Server = localhost, Port = 2036)
Model = (Ex.: shell_diffusion)

(At that point, your COMSOL model is in the COMSOL server/buffer and is named "shell_diffusion")

In MATLAB:
- Loading your COMSOL model that you sent in the COMSOL server:
>> model = ModelUtil.model('shell_diffusion');
- Saving the file as a MATLAB .m-file:
>> model.save(, 'm'); (Ex.: model.save('shell_diffusion2', 'm'); )
(The file would be saved by default in the current working folder)
- In order to save the file in a specific folder:
>> model.save('C:\COMSOL_Models\shell_diffusion2', 'm');

(You now have created a MATLAB .m-file from a COMSOL file which you can edit and modify)
(I know, you could have just use the File > Save as Model M-File... option in COMSOL but I don't know how you could resend it to COMSOL that way)

- To save your modified model back into COMSOL:
>> model.save('C:\COMSOL_Models\shell_diffusion3'); (No specific file extension will save it as a .mph COMSOL file)


(You now have your COMSOL file back which you can reopen in COMSOL)
http://phonies4.rssing.com/chan-3365787/all_p93.html

-------------------------------tutorials (youtube) comsol 4.2
for absolute beginners

1) http://www.youtube.com/watch?v=aWYs2EjexhU
how to use an example

2)  http://www.youtube.com/watch?v=E79iMme2kpo

ex: 2D
explain "addd physics" (equations) without programming and math;
electromagnetics, frequency domain (light)
flag=finish

3) geometry
http://www.youtube.com/watch?v=NwVQnim3f-k
http://www.youtube.com/watch?v=fqLQpHlTFS4
(2objectx->union->one object)
http://www.youtube.com/watch?v=vLrNZD9lBdw
(grossir un objet; faire une N-copie d'un objet: array)

6)global parameters:
http://www.youtube.com/watch?v=M1F0HBORBkM

7/defining materials
http://www.youtube.com/watch?v=KlUCtVU4bm4

8) meshing
http://www.youtube.com/watch?v=58GHDdR1HUg

9)
http://www.youtube.com/watch?v=gkWjA8yN-X8
Setting up RF-Physics

10)Simulation and Analysis
http://www.youtube.com/watch?v=daIRsiBQgEY

11) Analysis: Integration
http://www.youtube.com/watch?v=zuUMj54iXus

12) Parameteric Sweep
http://www.youtube.com/watch?v=N784M5Mkp0o

13) Create Animation, Video, Movie
http://www.youtube.com/watch?v=XnT45kzu53c

14) Extract Data from Simulation, Line Scan, Line Graph
http://www.youtube.com/watch?v=wyhYBH5M3oM


---------------------- for "beginners" (quite complex geometry: nanoparticle and concentric spheres):
http://www.youtube.com/watch?v=fXm1GKXDXM0
This tutorial is the first on a series of 3. Shows how to build a model step by step. Electromagnetic waves scattering off of a nano sphere. Use of work planes and revolve. Material properties .

part2 and 3:
http://www.youtube.com/watch?v=DkY4vaKo72w
http://www.youtube.com/watch?v=Wdkmq6X1Aak
---------
Comsol Step by Step: Refraction, Total Internal Reflection (comsol 4.2)
http://www.youtube.com/watch?v=He8XXyut-98
------
cantilevel & comsol 4.2
part 1/5:
http://www.youtube.com/watch?v=k-4bjO1Cq-4
-----
poisson equation/sphere/equation 2 forms for parameters:
http://www.youtube.com/watch?v=sMJTWa-Z9Ho&feature=share&list=UUrx4DqkACEdL_cV8eDQ-_7g
-----
Comsol Tutorial How to draw a coil
http://www.youtube.com/watch?v=qeKLP1-7-80
----
meshing:
http://www.youtube.com/watch?v=58GHDdR1HUg
------
Postprocessing Tutorial: Creating a Plot in COMSOL Multiphysics
http://www.youtube.com/watch?v=MSIa5cMvM4Q
This video tutorial depicts the basics of how to generate plots and how to tweak the different visualization options in order to create the optimal display of results for your COMSOL model. A 2D plot group is created and multiple 2D plot types are superimposed so multiple variables can be displayed simultaneously. The plot types demonstrated here include: Surface, Arrow Surface, Contour, Deformation, and Height Expression.
-----
How to 3D Print COMSOL Models
http://www.youtube.com/watch?v=Q9HYGaSwr90


-------------------------------some video of models in neuroscience

COMSOL Multiphysics CoW Bloodflow simulation
http://www.youtube.com/watch?v=UjkC23XKbic
This is a COMSOL model I created for my Biotransport Phenomena course. It simulates blood flow velocity through the Circle of Willis, an arterial network in the brain. It simulates multiple heartbeats at a HR of 60bpm.

Pyramidal Neurons Firing
http://www.youtube.com/watch?v=RTwY1naafGQ
MATLAB vector containing firing patterns is used as the input function for the COMSOL model.

-------------------------------






Tuesday, July 2, 2013

GoogleServe 2013, google and help : more than 8,500 Googlers from 75+ offices participated in 500 projects

Every year in June comes a week where Googlers around the world stop reviewing code, ignore their inboxes and leave their cubicles behind to participate in GoogleServe, our global week of service. 

Not only was this our largest GoogleServe to date, but it was also one of the more unique, as many projects were designed to expand the notion of what it means to give back to the community. Here’s a glimpse at some of what we were up to this year:

  • In Thimphu, Bhutan, Googlers led a workshop about media literacy at the Bhutan Centre for Media and Democracy helping youth prepare to participate in shaping the future of this young democracy.
  • Googlers in Mountain View, Calif., created a bone marrow donation drive and partnered with the Asian American Donor Program to raise awareness about the need for more donors from diverse racial and ethnic backgrounds.
  • Googlers from our Hyderabad, India office volunteered at Sri Vidhya's Centre for the Special Children, helping children who suffer from a wide range of cognitive disabilities to learn how to identify colors, write their own names, and prepare meals for themselves.
  • A team of Googlers walked the New York, N.Y., streets gathering information to improve AXS Map, a crowd-sourced platform for mapping wheelchair accessibility which is populated with data from Google Maps and Google Places APIs.
  • In Lagos, Nigeria, Googlers mentored entrepreneurs at Generation Enterprise, a small business incubator that equips at-risk youth to start sustainable businesses in slum communities.
  • In Randwick, Australia, Googlers taught computer and Internet skills with the Australian Red Cross Young Parents Program which aims to develop the capacities of young parents to live independently and to parent successfully.
  • A group of gourmet Googlers cooked a meal for families with children undergoing cancer treatment with Ronald McDonald House in London, U.K.
  • Googlers tutored and mentored youth in Kuala Lumpur, Malaysia, with the Dignity For Children Foundation.
  • Googlers partnered with Un Techo Para Mi País to help build a new house for a family living below the poverty line in Bogota, Colombia.
  • In Dublin, Ireland, Google engineers taught youth how to program interactive stories and games with Scratch in partnership with Coder Dojo.

REF: http://googleblog.blogspot.fr/2013/06/googleserve-2013-giving-back-on-global.html