Thursday, March 9, 2017


Dicom Image Scan Time



The Dicom tags of image scan time typically used are:

0008,0020: Study date;        0008,0030: Study time
0008,0021: Series date;      0008,0031: Series time
0008,0022: Acquis date;      0008,0032: Acquis time
0008,0023: Image date;       0008,0033: Image time

where Image date and time also called Content date and time.

Study date and time are generally used as the beginning of the radiologist starting to work on the scanner for the particular patient.

Series date and time/Acquisition date and time are kind of similar, logically series date and time are the starting point of a series image or in another word, the image volume. That is, they are different between volumes. However, because some volumes are secondary image derived from primary images, there could be different Series data and time of volumes shared the same Acquisition date and time.

Image date and time(Content  date and time) is the starting point of each single image slice.

Wednesday, March 8, 2017

Global Variable in MATLAB
The following information should help you understand how to use global variables and MATLAB workspaces.
MATLAB Workspaces
In order to understand global variables, you must first understand variables as they are normally stored in MATLAB.
All variables in MATLAB are stored in a workspace. 
When manipulating data at the command line, the variables are stored in the MATLAB base workspace. The contents of this workspace can be displayed by using the whos command.
MATLAB functions have their own workspaces, separate from the MATLAB workspace. Variables defined in this function workspace are automatically cleared from memory when the function returns.
MATLAB script files store all variables in the calling workspace. 
  - If a MATLAB script is called from the command line, the variables are stored in the base workspace. 
  - If the same script is called from a function, the script stores its variables in the function's workspace, and the variables are cleared when the function returns.
There is also a third type of workspace, the global workspace, where all global variables are stored. The contents of this workspace can be seen by using the whos global command. You cannot work directly in the global workspace, but variables in another workspace can be declared global using the GLOBAL command.
Creating Global Variables
Global variables are created using the global command. When the command
        global my_x
is issued, the following process occurs:
  1. If a variable called my_x exists in the global workspace, then its value is assigned to the local workspace's variable my_x. Any existing local variable my_x has its value overwritten.
  2. If no variable called my_x exists in the global workspace, but there is a variable my_x in the current workspace, then the local variable my_x is placed in the global workspace.
  3. If no variable exists in either the current workspace or the global workspace, then a new variable my_x is created and given the value [] (the empty matrix). This new variable is placed in the global workspace.
  4. The local variable and the global variable are then linked.

Note that there is opportunity for confusion here. Suppose you want a function MyFun to share a global variable, my_x, with the main MATLAB workspace, where it has a value. If you declare my_x global in MyFun first, then the global value for my_x becomes [], the empty matrix. If you then declare my_x global in the main MATLAB workspace, this empty matrix overwrites the local value for my_x, and its initial value is lost. Declaring the variable global in the main MATLAB workspace first, and then in MyFun, does the right thing -- the initial value for my_x is retained. Care must be taken to avoid this kind of mistake.
Tips for Working with the Global Workspace
Use care when naming global variables. Since all functions use the same global workspace, naming conflicts can easily occur. To avoid this, use unique, descriptive variable names for all global variables. Since variable names are case sensitive, capitalization can also be used to keep global variable names unique. For example, instead of using x, use Selected_X_Coord.
The commands CLEAR, WHO, and WHOS normally apply to the current workspace. These commands take an optional argument, global, which specifies that the command should be applied to the global workspace. For example, to show the contents of the global workspace, type at the MATLAB prompt:
    whos global
Clearing a variable from the local workspace (using 'clear my_x') breaks the link between the local and global variables, but does not erase the global variable.
Clearing a variable from the global workspace (using 'clear global my_x') completely erases the variable my_x from the local and global workspaces.
The ISGLOBAL function can be used to determine if a link exists between a local variable and the global workspace. This function does not determine if a variable exists in the global workspace; if the variable exists in the global workspace, but no link exists from a local variable, ISGLOBAL returns a zero (false).
The command PACK clears all variables from the global workspace. After PACK is issued, the global workspace is empty, and no variables have links to the global workspace. Therefore, take care when using the PACK command to re-declare variables as global after making the call to PACK.
Relevant commands: clear, global, isglobal, who, whos, pack

source: https://www.mathworks.com/matlabcentral/answers/99602-how-can-i-use-global-variables-and-matlab-workspaces

Tuesday, March 7, 2017

Use PostgreSQL database from R

Use PostgreSQL database from R
# install.packages("RPostgreSQL")
require("RPostgreSQL")
# create a connection
# save the password that we can "hide" it as best as
# we can by collapsing it
pw <- {
  "new_user_password"
}
# loads the PostgreSQL driver
drv <- dbDriver("PostgreSQL")
# creates a connection to the postgres database
# note that "con" will be used later in each connection to the database
con <- dbConnect(drv, dbname = "postgres",
                 host = "localhost", port = 5432,
                 user = "openpg", password = pw)
rm(pw) # removes the password
# check for the cartable
dbExistsTable(con, "cartable")
# TRUE

Now let’s open up a database connection and insert the table.
# Create a connection to the database
library('RPostgreSQL')
## Loading required package: DBI pg = dbDriver("PostgreSQL") # Local Postgres.app database; no password by default
# Of course, you fill in your own database information here.

con = dbConnect(pg, user="ninazumel", password="",
host="localhost", port=5432, dbname="ninazumel")
# write the table into the database.
# use row.names=FALSE to prevent the query
# from adding the column 'row.names' to the table
# in the db

dbWriteTable(con,'iris',iris, row.names=FALSE)
## [1] TRUE
https://www.r-bloggers.com/getting-started-with-postgresql-in-r/
http://www.win-vector.com/blog/2016/02/using-postgresql-in-r/

NYSE:ORCL -- Oracle

26-03-11 ☁️ Oracle:杠杆的艺术 2026财年第三季度关键指标: ☁️营收增长加速(但存在一些问题):总营收达到 172 亿美元,同比增长 22%。按固定汇率计算,增长率仅为 18%,这意味着部分增长来自汇率波动,而非实际需求。 📦 积压订单持续攀升:RPO 达...