nibabel_001

NiBabel

Installation

Installation Testing

  1. Testing as usual with import nibabel;print(success);nibabel.test()

  2. import nibabel; print('Success!');nibabel.test()

Note: Before running advanced tests, please update all submodules of nibabel, by running git submodule update --init

I am running a simpple test, not the advanced one it ran for 15 minutes and gave me long listing. In the end it gave me error about Freesurfer other wise the rest test is passed.

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================== short test summary info ============================
FAILED freesurfer/tests/test_io.py::test_geometry - assert False
FAILED freesurfer/tests/test_io.py::test_write_annot_fill_ctab - assert False
FAILED streamlines/tests/test_streamlines.py::TestLoadSave::test_save_complex_file
FAILED streamlines/tests/test_streamlines.py::TestLoadSave::test_save_tractogram_file
FAILED streamlines/tests/test_tck.py::TestTCK::test_load_file_with_wrong_information
FAILED streamlines/tests/test_trk.py::TestTRK::test_load_file_with_wrong_information
FAILED streamlines/tests/test_trk.py::TestTRK::test_load_trk_version_1 - Asse...
FAILED tests/test_deprecated.py::test_futurewarning_mixin - IndexError: pop f...
FAILED tests/test_nifti1.py::test_extension_io - assert 0 == 1
FAILED tests/test_parrec.py::test_truncated_load - assert 0 == 1
FAILED tests/test_parrec.py::test_truncations - assert 0 == 1
FAILED tests/test_parrec.py::test_ADC_map - assert 0 == 2
FAILED tests/test_testing.py::test_clear_and_catch_warnings - assert 1 == 2
= 13 failed, 4648 passed, 105 skipped, 6 xfailed, 1 warning in 829.54s (0:13:49) =

What is this pakcage ?

  • It provides read write acees to commonly used Neuroimaging files which includes following format Description
type Description
Gifti NifTI

Start working

  • Import and use its exposed version nibabel.(__version__)

  • Reading a nifti file. nibabel.load(<filename>)

  • A file that is read is used in a variabel say anat_img = nibabel.load('sample.nii.gz'). This object knows the file shape and image affine ( array matrix) shape. Another attribute is dataobj that gives you the detail of where this object is pointing to.

  • The ouput of nibabel loaded object is an instance of nibabel.nifti1.Nifti1Image which get read in a memory. When it is printed it gives you the address as well for example 0x7fdbdc86b2e0..

  • One can see that the super class is of nibabel.nifti1. This class exposes number of ...file

  • The nibabel attribute dataobj is an object that point to an image array that get loaded.,it is of nibabel.arrayproxy.ArrayProxy ojbect.

  • Array proxies and proxy images are the techniques nibabel uses to load an image from disk, an array proxy is not the array itself but something that represents the array and can provide the array when we load it. It allows us to create the image object withou immediately loading all the array data from sik.

  • Proxy is used rightly because images with an proxy object like this one are called proxy images because the image data is the proxy points to the array data on disk.

  • To check if it is a proxy, nib.is_proxy(anat_img)

  • Image shape and affine shape can be found out using numpy object and to do so you need to get an object that points to an image.

  • And it is done using img_data = anat_img.get_fdata()). This method returns a numpy array object. Its shape attribute will give the same result as nibiabel object.

  • Following is done and shown below

import nibable as nb

print(nb.__version__)

anat_img = nibabel.load('sample.nii.gz')
anat_img.shape           # ()
anat_img.affine.sahpe   #
anat_img.header         # 

file_data = anat_img.get_fdata()
file_data.shape
file_data.affine.shape ?

Commonly used functions

  • nibable.load()

  • nibable.shape # a loaded object represents the image that knows its shape.

  • nibable.affine.shape #

Working directory

  • There is not need to have or set a working directory but it is better to set a data directroy do avoid platfrom specific details.

Nibabel Images and its image object

  • It is composed of 3 items:

  • an N-D array containing the image data;

  • a (4, 4) affine matrix mapping array coordinates to coordinates in some RAS+ world coordinate space (Coordinate systems and affines);
  • image metadata in the form of a header.

The word affine is used frequently in image transformation, subsquently the word affine array represents an array that is accessed by another array in a loop. Another term is affine transformation like linear transformation and it is used to correct image transoformation in image related works.

Introduction to matplot

Matplotlib

UserGuide

  • It is plotting library for 2D plotting used in academic publising on hardcopy and in interactive environment.
  • It can be used in Python script, in Python and IPython shells, Jupyter notebook, web application servers. These four...

What it can generate ?

How it is installed ?

  1. It can be installed as its own package
  2. With third party distribution
  3. From source, it can be built
  4. Clone the latest repo

Its Dependencies ? on [30 July 2020] Following is taken from documentation

txt

Python (>= 3.6)
FreeType (>= 2.3)
libpng (>= 1.2)
NumPy (>= 1.11)
setuptools
cycler (>= 0.10.0)
dateutil (>= 2.1)
kiwisolver (>= 1.0.0)
pyparsing

- To get the better user interface toolkit, optional can be insalled.

tk (>= 8.3, != 8.6.0 or 8.6.1): for the Tk-based backends;
PyQt4 (>= 4.6) or PySide (>= 1.0.3): for the Qt4-based backends;
PyQt5: for the Qt5-based backends;
PyGObject: for the GTK3-based backends;
wxpython (>= 4): for the WX-based backends;
cairocffi (>= 0.8) or pycairo: for the cairo-based backends;
Tornado: for the WebAgg backend;
For better support of animation output format and image file formats, LaTeX, etc., you can install the following:

ffmpeg/avconv: for saving movies;
ImageMagick: for saving animated gifs;
Pillow (>= 3.4): for a larger selection of image file formats: JPEG, BMP, and TIFF image files;
LaTeX and GhostScript (>=9.0) : for rendering text with LaTeX.

Concepts behind the matplotlib

  1. The work is done on many levels from general to specific.
  2. Once can visiulize data easily as well as control necessary high and low level detail.
  3. It is all done through object library so the more specific can be accused its less specific object.
  4. matplotlib is said to be the state-machine environment provide by matplotlib.pyplot module.

Pyplot is like a matlab environment, so should not be difficult. The first level in object hirararcy is the pyplot library. The user uses this object to draw figures and controls its attributes.

In [ ]:
import matplotlib.pyplot as pyplot
import numpy as np

fig = pyplot.figure()
fig.suptitle('No axes on this figure')

# Draw two by two figures ( that is four boxex)
fig.ax_lst = pyplot.subplots(2,2)
# Draw only one
fig.ax_lst = pyplot.subplots(1,1)
  • The above figure is just a description how easy it is to plat a figure, it is very simple and other software such as r, matplot provides the smae high level abstraction.

Note: Matplotlib figures and plots works with numpy arrays as input. Other libraries arrly-like object such as pandas np.matrix may or may not work. It is better that they can be converted to np.array object.

Using numpy to draw a sin funciton

In [56]:
# run above cells so that librararie are imported, if not, import them again

import matplotlib.pyplot as pyplot
import numpy as np 

x = np.arange(0,10,0.2)
y = np.sin(x)

# creating a figure and set of subplots. pyplot.subplots() creates two object at one time, it implicitly 
# creates a fig object and show a subplot created in ax
fig, ax = pyplot.subplots()

# Though ax points to a subplots objects, it is still empty so fill it
ax.plot(x,y)
pyplot.show()
2020-07-30T17:19:08.451113image/svg+xmlMatplotlib v3.3.0, https://matplotlib.org/
In [59]:
### What happened above ?

# `np.arange`, numpy has number of function that creates an array as shown below.
# The function above creates an arry startgin from 0 and ending to 10 with a difference of 0.2
import numpy;a = numpy.arange(0,10,0.2);a
Out[59]:
array([0. , 0.2, 0.4, 0.6, 0.8, 1. , 1.2, 1.4, 1.6, 1.8, 2. , 2.2, 2.4,
       2.6, 2.8, 3. , 3.2, 3.4, 3.6, 3.8, 4. , 4.2, 4.4, 4.6, 4.8, 5. ,
       5.2, 5.4, 5.6, 5.8, 6. , 6.2, 6.4, 6.6, 6.8, 7. , 7.2, 7.4, 7.6,
       7.8, 8. , 8.2, 8.4, 8.6, 8.8, 9. , 9.2, 9.4, 9.6, 9.8])
In [60]:
# We need to draw something, and we decided to draw the output of `sin` funciton so we saved the outpu in y variable
# The return value of `sin(x)` function that is a tuple and need to be printed using print(y)
b = np.sin(a) #print(y)
In [68]:
# Now we have x that goes from 0 to 10 with a difference of 0.2 that is we are going to plot 
# values of y against x. to plot a figure we need to use matplot.pyplot object. This method provides a subplot object that
# is very convinent to plotting any values using object within fig object 
import matplotlib.pyplot as plt;
fig, ax = plt.subplots()
2020-07-30T17:46:57.614660image/svg+xmlMatplotlib v3.3.0, https://matplotlib.org/
In [75]:
# The above draws only an empty figure, even though `plt.show()` is not even used explicitly. 
# pyplot to plot an object we have used the following
ax.plot(a,b)
pyplot.show()
In [77]:
### The above does not work it has to be done in one go
fig2,fx=plt.subplots()
fx.plot(a,b)
plt.show()
2020-07-30T18:03:06.413486image/svg+xmlMatplotlib v3.3.0, https://matplotlib.org/
In [ ]:
 

Reading and Writing Access using Nibabel

What is this pakcage ?

  • It provides read write acees to commonly used Neuroimaging files which includes many formats

Installation

  • Use pip install nibabel

Test installaiton

  • Use import nibabel; nibabel.(__version__);print('succeeded!')

Run builtin test

  • import nibabel; nibabel.test()

Start working

  • Import and use its exposed version nibabel.(__version__)

  • Reading a nifti file. nibabel.load(<filename>)

  • A file that is read is used in a variabel say anat_img = nibabel.load('sample.nii.gz'). This object knows the file shape and image affine ( array matrix) shape. Another attribute is dataobj that gives you the detail of where this object is pointing to.

  • The ouput of nibabel loaded object is an instance of nibabel.nifti1.Nifti1Image which get read in a memory. When it is printed it gives you the address as well for example 0x7fdbdc86b2e0..

  • One can see that the super class is of nibabel.nifti1. This class exposes number of ...file

  • The nibabel attribute dataobj is an object that point to an image array that get loaded.,it is of nibabel.arrayproxy.ArrayProxy ojbect.

  • Array proxies and proxy images are the techniques nibabel uses to load an image from disk, an array proxy is not the array itself but something that represents the array and can provide the array when we load it. It allows us to create the image object withou immediately loading all the array data from sik.

  • Proxy is used rightly because images with an proxy object like this one are called proxy images because the image data is the proxy points to the array data on disk.

  • To check if it is a proxy, nib.is_proxy(anat_img)

  • Image shape and affine shape can be found out using numpy object and to do so you need to get an object that points to an image.

  • And it is done using img_data = anat_img.get_fdata()). This method returns a numpy array object. Its shape attribute will give the same result as nibiabel object.

Start reading ( loading ) an image.

In [7]:
import nibabel as nib 
img = nib.load('data/oxf/ExBox1/STRUCT0001.nii.gz')

# gets its attribute
print(img.shape)            # it will use (img.header.get_data_shape())
print(img.affine.shape)    # 
print(img.dataobj)
header = img.header
print(header)
print(header.get_data_shape())
print(header.get_data_dtype())
print(header.get_zooms()) # voxel in milimiter, and the time between scans in ms, it is the lst value.
(192, 256, 256)
(4, 4)
<nibabel.arrayproxy.ArrayProxy object at 0x7f1493ccc2b0>
<class 'nibabel.nifti1.Nifti1Header'> object, endian='<'
sizeof_hdr      : 348
data_type       : b''
db_name         : b''
extents         : 0
session_error   : 0
regular         : b'r'
dim_info        : 0
dim             : [  3 192 256 256   1   1   1   1]
intent_p1       : 0.0
intent_p2       : 0.0
intent_p3       : 0.0
intent_code     : none
datatype        : int16
bitpix          : 16
slice_start     : 0
pixdim          : [-1.         1.0500001  1.         1.         5.         0.
  0.         0.       ]
vox_offset      : 0.0
scl_slope       : nan
scl_inter       : nan
slice_end       : 0
slice_code      : unknown
xyzt_units      : 10
cal_max         : 1218.0
cal_min         : 0.0
slice_duration  : 0.0
toffset         : 0.0
glmax           : 0
glmin           : 0
descrip         : b'5.0.10'
aux_file        : b''
qform_code      : scanner
sform_code      : scanner
quatern_b       : 0.0
quatern_c       : 1.0
quatern_d       : 0.0
qoffset_x       : 103.30165
qoffset_y       : -119.3996
qoffset_z       : -128.21066
srow_x          : [ -1.0500001   0.          0.        103.30165  ]
srow_y          : [   0.        1.        0.     -119.3996]
srow_z          : [   0.         0.         1.      -128.21066]
intent_name     : b''
magic           : b'n+1'
(192, 256, 256)
int16
(1.0500001, 1.0, 1.0)
In [ ]:
> Most of the header information are not directly accessebile but retrieved  by using  getter `obj.get_dtype()` etc.

Image data

  • An image array can also be stored in the image object as numpy array.
  • To get more about image data, we can get a handle to dataobj that is returned by this function image_data = img.get-fdata(). It is a numpy.ndarray object that represents the data object.
  • Image data object contains all the information that we can directly retrieved by using an image header object. It is another way to represent the data. For example header.get_dtype() will give same result as img_data.dtype.
In [12]:
import nibabel as nib
anat_img = nib.load('data/oxf/ExBox1/STRUCT0001.nii.gz')
anat_img_data = anat_img.get_fdata()

print(type(anat_img_data))
print("*********************************")
print(anat_img_data)
print("*********************************")

print(anat_img_data.shape)
print(anat_img_data.dtype)
<class 'numpy.ndarray'>
*********************************
[[[33. 27. 17. ...  1.  0.  0.]
  [19.  0.  2. ...  0.  0.  0.]
  [29.  4.  5. ...  0.  0.  0.]
  ...
  [17.  2.  5. ...  1.  1.  0.]
  [10.  5. 11. ...  1.  1.  0.]
  [ 0.  0.  0. ...  0.  0.  0.]]

 [[11. 20.  7. ...  1.  0.  0.]
  [11. 18. 10. ...  0.  0.  0.]
  [10.  4.  5. ...  1.  1.  0.]
  ...
  [14. 15.  7. ...  0.  1.  0.]
  [ 7. 12. 11. ...  1.  1.  0.]
  [ 0.  0.  0. ...  0.  0.  0.]]

 [[ 7.  4. 18. ...  1.  0.  0.]
  [ 3.  4. 20. ...  1.  1.  0.]
  [ 9.  7. 22. ...  0.  1.  0.]
  ...
  [14. 13.  9. ...  1.  1.  0.]
  [ 5.  5. 15. ...  1.  0.  0.]
  [ 0.  0.  0. ...  0.  0.  0.]]

 ...

 [[16. 17.  9. ...  0.  0.  0.]
  [19. 14.  8. ...  1.  0.  0.]
  [30. 15. 15. ...  1.  0.  0.]
  ...
  [ 0.  9.  5. ...  0.  0.  0.]
  [ 0.  6. 10. ...  1.  0.  0.]
  [ 0.  0.  0. ...  0.  0.  0.]]

 [[23. 16. 16. ...  1.  0.  0.]
  [10. 28. 24. ...  0.  0.  0.]
  [ 1. 12. 15. ...  0.  1.  0.]
  ...
  [ 7. 11. 16. ...  1.  1.  0.]
  [11.  1.  5. ...  0.  1.  0.]
  [ 0.  0.  0. ...  0.  0.  0.]]

 [[20. 27.  3. ...  1.  0.  0.]
  [21. 22. 24. ...  0.  0.  0.]
  [ 0. 19. 44. ...  0.  0.  0.]
  ...
  [15.  4.  7. ...  0.  0.  0.]
  [12.  4.  4. ...  1.  0.  0.]
  [ 0.  0.  0. ...  0.  0.  0.]]]
*********************************
(192, 256, 256)
float64
In [32]:
# As we saw, that the retruned data object is of `numpy.ndarry `. We can also create an image of `numpy arrays` 
import numpy as np
array_data = np.arange(24, dtype=np.int16)
print(array_data)

print ("*------------------------*")
array_data = array_data.reshape(2,3,4)
print(array_data)
print ("*------------------------*")
affine = np.diag([1,2,3,1])
print(affine)
array_img = nib.Nifti1Image(array_data,affine)
print(array_img)
print(array_img.dataobj)
[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23]
*------------------------*
[[[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]

 [[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]]
*------------------------*
[[1 0 0 0]
 [0 2 0 0]
 [0 0 3 0]
 [0 0 0 1]]
<class 'nibabel.nifti1.Nifti1Image'>
data shape (2, 3, 4)
affine: 
[[1. 0. 0. 0.]
 [0. 2. 0. 0.]
 [0. 0. 3. 0.]
 [0. 0. 0. 1.]]
metadata:
<class 'nibabel.nifti1.Nifti1Header'> object, endian='<'
sizeof_hdr      : 348
data_type       : b''
db_name         : b''
extents         : 0
session_error   : 0
regular         : b''
dim_info        : 0
dim             : [3 2 3 4 1 1 1 1]
intent_p1       : 0.0
intent_p2       : 0.0
intent_p3       : 0.0
intent_code     : none
datatype        : int16
bitpix          : 16
slice_start     : 0
pixdim          : [1. 1. 2. 3. 1. 1. 1. 1.]
vox_offset      : 0.0
scl_slope       : nan
scl_inter       : nan
slice_end       : 0
slice_code      : unknown
xyzt_units      : 0
cal_max         : 0.0
cal_min         : 0.0
slice_duration  : 0.0
toffset         : 0.0
glmax           : 0
glmin           : 0
descrip         : b''
aux_file        : b''
qform_code      : unknown
sform_code      : aligned
quatern_b       : 0.0
quatern_c       : 0.0
quatern_d       : 0.0
qoffset_x       : 0.0
qoffset_y       : 0.0
qoffset_z       : 0.0
srow_x          : [1. 0. 0. 0.]
srow_y          : [0. 2. 0. 0.]
srow_z          : [0. 0. 3. 0.]
intent_name     : b''
magic           : b'n+1'
[[[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]

 [[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]]
In [ ]:

checking the data type

  • An image data object can be of array_img.dataobject, farray_img.dataobj
In [14]:
if anat_img_data is array_img.dataobj:
    print("It is of array_img.dataobj")
elif anat_img_data is farray_img.dataobj:
    print("It is of arry_img.dataob")
else:
    print("unknown data dyte")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-14-4c9ab58e1037> in <module>
----> 1 if anat_img_data is array_img.dataobj:
      2     print("It is of array_img.dataobj")
      3 elif anat_img_data is farray_img.dataobj:
      4     print("It is of arry_img.dataob")
      5 else:

NameError: name 'array_img' is not defined
In [ ]:
### Image slicing

-

### Loading and Saving

- 
In [ ]:
import matplotlib.pyplot as plt 
def show_slices(slices):
    ''' Function to desplay row of image slices '''
    fig, axes = plt.subplots(1, len(slices))
    for i, slice in enumerate (slices):
        axes[i].imshow(slice.T, cmap="gray", origin="lower")
    
slice_0 = epi_img_data[96, :, :]
print(len(slice_0))
slice_1 = epi_img_data[:, 128, :]
slice_2 = epi_img_data[:, :, 128]
show_slices([slice_0,slice_1,slice_2])
plt.suptitle("Center slices for EPI image")
In [ ]:
 
In [ ]:
 
In [ ]:
# Get the header of the data
cwd = os.getcwd()
data_dir = cwd + "/data/ds000114/"
print(data_dir)
#print("file header only" + header)

Neuro Imagin with Machine Learning

What is nilearn 1.0 ?

  • nilearn is a python way of doing work (statistical analysis) with Neuro Imaging in Python using machine learning. It uses scikit-learn Python toolbox.
  • It is a subset of a family of work done in python language related with Neuro Imaging.
  • It is not a new technique or new science but provides modern pythonic way of dealing with old analysis done on neuro imaging data such as MVPA, decoding, predictive modelling, functional connectivity, brain parcellations, connectomes.
  • It can also be used on different modalaties of fMRI such as task fMRI, resting fMRI, or VBM data
  • nilearn makes the work of neuro imaging with machine learning a specific domain, or feature engineering construction.

Installation 1.1

  • Use pip install -U nilearn or use existing conda environment to install nilearn

Check installation 1.2

  • Following line will check its installaiton.
In [1]:
import nilearn as ni
In [3]:
ni.version
Out[3]:
<module 'nilearn.version' from '/home/sayyed/anaconda3/envs/nipype/lib/python3.8/site-packages/nilearn/version.py'>
In [4]:
from nilearn import plotting
In [5]:
# Plotting glass brain
plotting.plot_glass_brain("data/sample-nifiti-file.nii")
Out[5]:
<nilearn.plotting.displays.OrthoProjector at 0x7fde728a2100>
In [6]:
# plotting anatomical brain.
plotting.plot_anat("data/sample-nifiti-file.nii")
Out[6]:
<nilearn.plotting.displays.OrthoSlicer at 0x7fde6f4886d0>
In [7]:
# plotting
plotting.plot_epi("data/sample-nifiti-file.nii")
Out[7]:
<nilearn.plotting.displays.OrthoSlicer at 0x7fde6d874100>
In [9]:
# Using plot_img
plotting.plot_img("data/sample-nifiti-file.nii")
Out[9]:
<nilearn.plotting.displays.OrthoSlicer at 0x7fde6d62aeb0>
In [26]:
# To read dicom daga
import pydicom as pd 
import pydicom.data 
# To plot it
import matplotlib.pyplot as plot

base = "data/"
pass_dicom = "IM-0001-0001.dcm"
fn = pd.data.data_manager.get_files(base,pass_dicom)[0]
ds = pd.dcmread(fn)

# To view read image
plot.imshow(ds.pixel_array, cmap=plot.cm.bone)
Out[26]:
<matplotlib.image.AxesImage at 0x7fde850be490>
In [ ]:
 

nipype-workflow

My setup of nipype

  • I have successfully created a conda environment for nipype. it is located here (/home/sayyed/anaconda3/envs/nipype).
  • The directory I have chosen to work is /home/sayyed/neuro-science/projects/nikola the listing is given as below.
  • Since this package works with all existing neuroimaging software, it is recomended that it is installed on a machine where all other software can be installed and configured properly to work with nipype.
  • Once it is installed using conda install --channel conda-forge nipype. Its .yml file can be created using conda list --explicit > nipype.txt
  • Though the list is long but it does not install ipython or say a kernel so theat we can workwith jupyterlab. If ipython is installed , one can start the interactive shell and start working from terminal or command prompt. In reality ipython is not necessary as nipype install python packeage to srat with.
  • ipython is only necessary if you decide to work with Jupyter. It is same as python that is an interpreter but works interactively with Jupyter environment and hence knows as Python execusiton background in Jupyter environment.
  • Having said that ipykernel can still be installed in nipype environment using conda istall ipykernel. This will also install jupyter_cliend, core and other necessary packages. Once installed, ipython can be started from terminal and the availablity ofnipypepackage can be checked usingimport nipype as nyandny.get_info()`.
  • To check the proper installtion when the command was run it produced an error that pytest is not instlled use pip to install. So I did then ran a test.
  • When installation was tested using given instructions, it complained about the Sphinix extension documenter not found.
  • Furthermore, when example was started I encountered an error saying nilearn is not installed so I installed it as well.
  • today on 24 July 2020, I again encountered some problems so I read the instructions again and found that I need to install scikit-learning as well. So I installed it using conda -install scikit-learning. Aslo checked nilearn again and install it using conda install nilearn and one package was installed. It happened with nilearn as well all other dependencies were installed only this one was left.
  • To download data nipype uses a pyton module called datalad, use pip install datalad.
  • When working in notebook, I frequently encountered a problem with traversing the file path.
  • So I open the evironment in spyder but it says you need to install sypder kernel in your evnironment. so I did using pip install spyder-kernel. Then use `python -c "import sys; print(sys.executable)"
  • Once done you can open spyder from base environment and then using Preferences -> Python Interpreter -> select the python
  • While starting to work with given examples again encounter a problem so I ran a test nipype.test() and it said VTK was no found and nipype.interface WARNING: tvtk wasn't found, upgradeDIPY` verson.
  • Tried to upgrade and found that it is not installed so I installed using conda install DIPY. Then got thewarning Nipype 1 wrokflows have been moved to the niflow-nipype1-wrokflows padkage. pip install niflow-nipype1-wrokflows.
  • Got error about sphinix installed conda intall sphinx
  • Still getting an error about sphinxcontrib napoleon, using pip install sphinxcontrib-anpoleon though it said requirment already installed and instlled `pockets, shpinxcontrib-anpoleaon.
  • And finally import nipype; nipype.test() scucceded to run, it took 10 minutes or more to run and utilize all 8 processors, all memory and Gpu 3d up to 54%.
  • In the end one error I recieved and it was about workflow.
  • Today I ran another test using the following as mentioned in dcoument:
# Import the nipype module

import nipype

# Optional: Use the following lines to increase verbosity of output

nipype.config.set('logging', 'workflow_level', 'CRITICAL')
nipype.config.set('logging', 'interface_level', 'CRITICAL')
nipype.logging.update_logging(nipype.config)

# Run the test: Increase verbosity parameter for more info
nipype.test(doctests=False)
  • No this tiem I get this erro: ERROR: usage: ipykernel_launcher.py [options] [file_or_dir] [file_or_dir] [...] ipykernel_launcher.py: error: unrecognized arguments: --doctest-modules inifile: /home/sayyed/anaconda3/envs/nipype/lib/python3.8/site-packages/nipype/pytest.ini rootdir: /home/sayyed/anaconda3/envs/nipype/lib/python3.8/site-packages/nipype

  • This time again using conda install doctest installed a new packgage called doctest-2.4.0.... but the test did not suceeded.

> ~/n/p/nikola ll                                                                                                         (base) 17:32:36
total 52K
drwxrwxr-x 12 sayyed sayyed 4.0K Jul 10 21:35 demosite/
drwxrwxr-x  6 sayyed sayyed 4.0K Jul 18 00:27 Ex_01/
-rw-rw-r--  1 sayyed sayyed  28K Jul 16 18:15 installed-moudle.txt
drwxrwxr-x 13 sayyed sayyed 4.0K Jul 21 18:23 mysite/
lrwxrwxrwx  1 sayyed sayyed   31 Jul 21 16:11 nik-nip-vscode -> ./.vscode/Nikola.code-workspace
-rw-rw-r--  1 sayyed sayyed 8.1K Jul 16 18:13 requirement.txt
> ~/n/p/nikola    
  • The demosite I do not need and it will be deleted.
  • Mysite directory is the main directory of nikola blog.
  • The vsocde workspace is saved in .vscode folder and pointed by nik-nip-vscode link ( it is uselss at this moment)

How notebook differs when created in nikola or in jupyterlab?

  1. Notebook can be created in many ways. But when nikola does its scanning it throws an error if it does not find the meta data it requires for a notebook to be a part of the nikola.
  2. It does not matter where it can be created from, the meta data can be easily added. Inorder for nikola to open and work with notebook, it has to have some meta data inside it. It is not a rocket science as I had gread difficulty dealing with notebook when trying to open them with pelican or embed them in markdown file. Though I have not been successful to embed notebooks in markdown files using short code as described by nikola docuemtation.
  3. Follwing is a meta data entries when the file is created by jupter lab selecting particular ipython kernel. Ipython kernil is just a python interpreter name that you have created in your conda or pip environment and given it a uniqure name. For exampe when I created nipype environment I installed different version of differnt software that can work together. This version is knows as your particular python kernel or interpreter.
"metadata": {
  "kernelspec": {
   "display_name": "Python (nipype)", # This is added when you choose you particular python kernel
   "language": "python",
   "name": "nipype"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
  1. The above detail is enough for jupyter to open the file but not for nikola needs to know more to deal with correct theme and template to open notebook data. Follwing information is needed and can simply be added into the above meta data.
"nikola": {
   "author": "Abdul Sayyed",
   "category": "nipype",
   "date": "2020-07-10 15:43:54 UTC+01:00",
   "description": "",
   "link": "",
   "slug": "001_intro",
   "tags": "python, jupyter, nipype",
   "title": "001_intro",
   "type": "text"
  }

How to create a notebook with vscode.

  1. Using command pattlet we can use > create notebook command. There are other worth exploring as of importing as well.
  2. Running notebook in vscode and setting it properly can be handy. The scroll bar shows, wchic environmen is selected. If the wrong one is selected, by clicking on the status bar on the infromation it will open different environment where the right one can be opened. Once the right one is opened. The notebook already have installed module such as numpy, matplot or nipype exposed api avilable to use.
  3. On the right hand top corner, vscode also shows the local server and the right kernel selected.
  4. It is very handy that in my one notebook folder created in nikola top level directories, I can have different notebooks set and ready to be used with different environments.
  5. They can all be opened from one place and knows which environment they are to be used as in their meta contents this information is saved.
  6. If not the right kernel can be opened from the right corner.

Running code from different kernels

  • It is possible to run code from different kernel or executional environment in one note book.
  • Use %%bash or %%HTML or %% and run the particular command to execute it.

How this repo is committed

  1. Since I am using nikola, whatever I do I keep the work under mysite folder so that it is also published as well.
  2. I always work in dev branch. To publish my site , I switched to src by using git checkout src from here I use nikola github_deploy. This takes care of eveything and only deploy the output folder and whatever is necessary to produce a websit.
  3. I also wanted to be able to use my repo with windows so I cloned it to my windwos environment but realised that it does not have any contents, it is only a publish html file repo. No markdown contents.
  4. To resolve this issue I had to create a new repo which I named https://github.com/AbdulSayyed/nikola-website and added a remote in my local dev branch where I usually work from.
  5. To add a new remote to a same repo I used this command git remote add niksrc https://github.com/AbdulSayyed/nikola-website.git as shown below. Now I have my dev branch set to a remote repo name nikola-website.git. This branch is added or referenced in my config file as niksrc. To pus or pull I would use git push niksrc dev or git pull niksrc dev
 ~/n/p/n/mysite on dev  git remote add niksrc https://github.com/AbdulSayyed/nikola-website.git                      (nikola) 12:59:21
> ~/n/p/n/mysite on dev  git remote -v                                                                                (nikola) 12:59:43
niksrc  https://github.com/AbdulSayyed/nikola-website.git (fetch)
niksrc  https://github.com/AbdulSayyed/nikola-website.git (push)
origin  https://github.com/AbdulSayyed/AbdulSayyed.github.io.git (fetch)
origin  https://github.com/AbdulSayyed/AbdulSayyed.github.io.git (push)
> ~/n/p/n/mysite on dev  git status                                                                                   (nikola) 12:59:49
On branch dev
nothing to commit, working tree clean
> ~/n/p/n/mysite on dev  git push -u niksrc dev                                                                       (nikola) 13:00:10
Username for 'https://github.com': Abdulsayyed
Password for 'https://Abdulsayyed@github.com': 
Enumerating objects: 111, done.
Counting objects: 100% (111/111), done.
Delta compression using up to 8 threads
Compressing objects: 100% (97/97), done.
Writing objects: 100% (111/111), 259.39 KiB | 7.63 MiB/s, done.
Total 111 (delta 41), reused 6 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (41/41), done.
To https://github.com/AbdulSayyed/nikola-website.git
 * [new branch]      dev -> dev
Branch 'dev' set up to track remote branch 'dev' from 'niksrc'.
> ~/n/p/n/mysite on dev  git remote -v                                                                               (nikola) 13:01:08
niksrc  https://github.com/AbdulSayyed/nikola-website.git (fetch)
niksrc  https://github.com/AbdulSayyed/nikola-website.git (push)
origin  https://github.com/AbdulSayyed/AbdulSayyed.github.io.git (fetch)
origin  https://github.com/AbdulSayyed/AbdulSayyed.github.io.git (push)
> ~/n/p/n/mysite on dev     

The reason it was done because I was having difficulty with shared folder with VBox and Ubuntu 20.04. As there are some material, especially some images that I wanted to use with nikola site.

  • Though I have started working from both machine, I need to understand that I can only work or update the contents from one machine, push it to the remote. And then when starting to work again in another machine I need to pull a repo and started woking with it. I can not start to wrok in both machine with the same repo as it would created confilicts and I will loose my work.

Problems faced with working nipype.

  • It has been a week I have not been able to solve the issue with an error I recieved, it comes when this package tries to read the bids file. It does not give any error when reading but it doe when I use BET and tries to output.
  • I can not run nipype on windows.

When looking at the examples of nipype I found a new term BET

  • As I have not worked with FSL software but here is an overview of FSL software

  • Tools used in FSL:[Taken from FSL oxford]

  • fMRI:FEAT, MELODIC,FABBER, BASIL,VERBENA

  • sMRI: BET,FAST,FIRST,FLIRT, FNIRT, FSLVBM,SIENA, DIENAX,fsl_anat
  • dMRI: FDT,TBSS, eddy,topup
  • GLM/ Stats:.
  • other tools: FSLView, Fslutils,Atlases, Atlasquery, etc

  • BET or Brain Extaction Tool is uses to delete non-brain tissu from an image of the whle head. It is used to estimate the inner and outer cell surfaces and outer scapl surface out of T1 and T2 images.

Nipype introduction

Starting with nipype

  • Nipype probably pronouncec as nipee..yipee is an abbreviation for Neuroimaging in Python pipleline and interfaces
  • It is a Toolbox for anylysing data coming from neuroimaging modalaties. It is written in Python.
  1. Installation
  2. Check your installation

Beginners Guide

  1. It is year 2017 guide, it can be tested and re written for others
  2. The main purpose of this toolbox is to provide an easy way to build a workflow termed as a pipleline, to facilitate the existing technologies used in neuroimaging analyis. All popular technololgies such as SPM, FreeSurfer, FSL etccan be used.
  3. It allows to combine these techonolgies in an specifed workflow, it is what you decided to use which technology for which prupose.
  4. For example
  5. The whole idea is to provide an environment where reasearch can be reproduced with the same data by sharing with others.

Nipype architechture:

It consist of many components, important ones are interfaces,Workflow Engines and Execution Plugins.

  1. Interfaces are the python programs (scripts) that are used to interface with existing technologies like MATLAB,AFNI,ANTs etc.
  2. Workflow Engine is a part that deals with the complexities involve in executing diferent task by gluing eachother. It uses following terms interchanably.
    • Node:An interface needs the information about the technologies it is dealing with and it is given in the form of node. A node describes these information.
    • MapNode:It is similar to node and takes multiple inputs of same type. For example 10 patient of same data analysis is performed on them.
    • Wordflow:It is graph a kind of directed acyclic graph or forest of grapsh that describes the dataflow interms of its Nodes, MapNodes or Workflows it self.
    • Execution Plugins: They descirbe how to execute your workfow in a physical machine by leaverging the power of differnet cores.

A conventional way of neuro imaging

  1. Acqusation of MRI data: you need to know how it is taken what varibales and terms are used. Which series of MRI is uses commonly known as modalaties. There are many like ( DTI, fMRI etc).
  2. The format of resulted images: Different scanners uses different formats e.g. DICOM , PAR or REC. To analyse these images they are to be converted into different format so that un necessary details can be removed. Initially data is kept in K-space and converted into different space. Mostly the format used is either nifti and now recetnly is gifti.
  3. Design of the experiment: Which kind of experimental design is used what parameters to take into accunt etc.
  4. Preprocessing of data:
    • Slice Timing Correction (fMRI images needes to be correcyted )
The below is taken verbatim from nipype Micheal tutorial.

Because functional MRI measurement sequences don’t acquire every slice in a volume at the same time we have to account for the time differences among the slices. For example, if you acquire a volume with 37 slices in ascending order, and each slice is acquired every 50ms, there is a difference of 1.8s between the first and the last slice acquired. You must know the order in which the slices were acquired to be able to apply the proper correction. Slices are typically acquired in one of three methods: descending order (top-down); ascending order (bottom-up); or interleaved (acquire every other slice in each direction), where the interleaving may start at the top or the bottom. (Left: ascending, Right: interleaved)

Slice Timing Correction is used to compensate for the time differences between the slice acquisitions by temporally interpolating the slices so that the resulting volume is close to equivalent to acquiring the whole brain image at a single time point. This temporal factor of acquisition especially has to be accounted for in fMRI models where timing is an important factor (e.g. for event related designs, where the type of stimulus changes from volume to volume).

Chec If nipype is working use import nipype or import nipype. Run the cell if gets error it means it is not working otherwise it is present.

  • Thouth the module has been imported successfully but it does not have any attribute or any function help() it thorws an error. The above command succeeded, it means it is working. we have nipype on our path. To see where it is loaded from use shift + tab

Getting ready for dataset

  • Make a directory data in current folder that is underneate your notebook folder. Then using datalad install dataset. Note the cell is used to execute bash programe, here it is refered as bash kernel. Other kernels can be used as well.
In [18]:
%%bash
mkdir -p data
cd data
datalad install -r ///workshops/nih-2017/ds000114
install(ok): /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114 (dataset)
install(ok): /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/fmriprep (dataset)
install(ok): /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/freesurfer (dataset)
action summary:
  install (ok: 3)
[INFO] Cloning dataset to <Dataset path=/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114> 
[INFO] Attempting to clone from http://datasets.datalad.org/workshops/nih-2017/ds000114 to /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114 
[INFO] Attempting to clone from http://datasets.datalad.org/workshops/nih-2017/ds000114/.git to /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114 
[INFO] Completed clone attempts for <Dataset path=/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114> 
[INFO] access to 1 dataset sibling datalad not auto-enabled, enable with:
| 		datalad siblings -d "/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114" enable -s datalad 
[INFO] Installing <Dataset path=/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114> underneath /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114 recursively 
[INFO] Cloning dataset to <Dataset path=/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/fmriprep> 
[INFO] Attempting to clone from http://datasets.datalad.org/workshops/nih-2017/ds000114/derivatives/fmriprep/.git to /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/fmriprep 
[INFO] Completed clone attempts for <Dataset path=/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/fmriprep> 
[INFO] Cloning dataset to <Dataset path=/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/freesurfer> 
[INFO] Attempting to clone from http://datasets.datalad.org/workshops/nih-2017/ds000114/derivatives/freesurfer/.git to /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/freesurfer 
[INFO] Completed clone attempts for <Dataset path=/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/derivatives/freesurfer> 
  • Looking into the dataset.
In [19]:
ls data/ds000114/
CHANGES                   sub-08/
dataset_description.json  sub-09/
derivatives/              sub-10/
dwi.bval@                 task-covertverbgeneration_bold.json
dwi.bvec@                 task-covertverbgeneration_events.tsv
sub-01/                   task-fingerfootlips_bold.json
sub-02/                   task-fingerfootlips_events.tsv
sub-03/                   task-linebisection_bold.json
sub-04/                   task-overtverbgeneration_bold.json
sub-05/                   task-overtverbgeneration_events.tsv
sub-06/                   task-overtwordrepetition_bold.json
sub-07/                   task-overtwordrepetition_events.tsv
In [34]:
# We have one anatomical image in every folder. Lets make sure it is there.
!ls data/ds000114/sub-01/ses-test/anat/
sub-01_ses-test_T1w.nii.gz

Using BET from fsl that we imorted in first step.

In [9]:
import os
from os.path import abspath

from nipype import Workflow, Node, MapNode, Function
from nipype.interfaces.fsl import BET, IsotropicSmooth, ApplyMask

from nilearn.plotting import plot_anat
%matplotlib inline
import matplotlib.pyplot as plt
from nipype.testing import  example_data
In [14]:
# reading file in a variable
working_dir = os.getcwd()
data_dir = working_dir + "/data"
print(data_dir)
input_file =  abspath(data_dir + "/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w")
print(input_file)
fn = "./sub-01_ses-test_T1w.nii.gz"
/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data
/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w
In [ ]:
 
In [19]:
bet = BET()
bet.inputs.in_file = input_file
bet.inputs.out_file = "T1.nii.gz"
res = bet.run()
---------------------------------------------------------------------------
TraitError                                Traceback (most recent call last)
<ipython-input-19-8f66ff4bee62> in <module>
      1 bet = BET()
----> 2 bet.inputs.in_file = input_file
      3 bet.inputs.out_file = "T1.nii.gz"
      4 res = bet.run()

~/anaconda3/envs/nipype/lib/python3.8/site-packages/nipype/interfaces/base/traits_extension.py in validate(self, objekt, name, value, return_pathlike)
    328     def validate(self, objekt, name, value, return_pathlike=False):
    329         """Validate a value change."""
--> 330         value = super(File, self).validate(objekt, name, value, return_pathlike=True)
    331         if self._exts:
    332             fname = value.name

~/anaconda3/envs/nipype/lib/python3.8/site-packages/nipype/interfaces/base/traits_extension.py in validate(self, objekt, name, value, return_pathlike)
    133         if self.exists:
    134             if not value.exists():
--> 135                 self.error(objekt, name, str(value))
    136 
    137             if self._is_file and not value.is_file():

~/anaconda3/envs/nipype/lib/python3.8/site-packages/traits/base_trait_handler.py in error(self, object, name, value)
     72             The proposed new value for the attribute.
     73         """
---> 74         raise TraitError(
     75             object, name, self.full_info(object, name, value), value
     76         )

TraitError: The 'in_file' trait of a BETInputSpec instance must be a pathlike object or string representing an existing file, but a value of '/home/sayyed/neuro-science/projects/nikola/mysite/notebooks/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w' <class 'str'> was specified.

Start working with nipype

  1. Importing few things
In [3]:
import os
from os.path import abspath
from os.path import relpath

from nipype import Workflow, Node, MapNode, Function
from nipype.interfaces.fsl import BET, IsotropicSmooth, ApplyMask

from nilearn.plotting import plot_anat
%matplotlib inline
import matplotlib.pyplot as plt
In [3]:
# will use a T1w from ds000114 dataset
input_file =  abspath("/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz")
In [5]:
bet = BET()
bet.inputs.in_file = abspath("data/sample-nifiti-file.nii")
bet.imputs.int_file= input_file
help(bet.inputs)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-125541a3dc72> in <module>
      1 bet = BET()
      2 bet.inputs.in_file = abspath("data/sample-nifiti-file.nii")
----> 3 bet.imputs.int_file= input_file
      4 help(bet.inputs)

NameError: name 'input_file' is not defined
In [17]:
bet.inputs.out_file = "sample_bet.nii.gz"
res = bet.run()
res.outputs
Out[17]:
inskull_mask_file = <undefined>
inskull_mesh_file = <undefined>
mask_file = <undefined>
meshfile = <undefined>
out_file = /home/sayyed/neuro-science/projects/nikola/mysite/notebooks/sample_bet.nii.gz
outline_file = <undefined>
outskin_mask_file = <undefined>
outskin_mesh_file = <undefined>
outskull_mask_file = <undefined>
outskull_mesh_file = <undefined>
skull_file = <undefined>
skull_mask_file = <undefined>
In [18]:
plot_anat("sample_bet.nii.gz", 
          display_mode='ortho', dim=-1, draw_cross=False, annotate=False);
In [ ]:
 

Reasearch Methods

This course is about searching online Database for research purpose and be able to critically evaluate scientific paper and put down the review in an SLR ( Structured Literature Review) essay which is the demand in academia.

Objectives

  • How to be a Research Psychologist / Scientist
  • Be familiar with theoretical and practical complexities involved
  • How to develop oneself to be a Researcher
  • Be able to use Qualitative & Quantitative techniques
  • Become an independent Researcher
  • Become proficient in Scientific Writings, skills and technique
  • Learn to use Google Scholars and other dedicated Search Engines
  • Be aware of Neuro ethics

Module Assessment

Two written assessments required

+ 010-Structured Literature Review [due date: 18th November 2018]
+ 011-Critical Research [due date: 06/01/2019]
  1. Element-010: An Essay of ( 2500-3000 ) words long on SLR of a Psychological topic related to your research interest i.e, Final Dissertation. { 60 %}

  2. Element-011: An essay, critically reviewing a recent ( within last 5 years) Scientific Paper ( published and peer reviewed Research Paper) related to your dissertation.

No Book is required but must see reading list

Week-1: On-line Database and Structured Literature Review

  1. Conducting a structured literature Review ( SLR )

Understanding Sources of information

- Sources of Information are commonly categorized as "Primary" or "Secondary" depending upon their emergence and originality and work done on them.
  • A Primary source is a first hand account of an event or a thing which includes original material e.g., a discovery of a site or an object or an unusual event containing some information.

  • While Secondary source is based upon Primary source so the research is done on Primary material to come up with some conclusions of what happened or what would have happened etc.

Examples of Primary and Secondary Sources


Primary Secondary Examples
----------------------- ------------------------------- -------------
Personal Diary Research done on it Famous Authors' Work
Interview, survey Review on Work done Critics' works
Original Speeches Future interpretation Politician's speech
Patents, Technical Reports Articles written about them Critical Review
Original Document, birth cert,etc. TextBooks, Criticism Challenge the authenticity
Experimental search Result Article and Journal on Result Result Challenge
Art, Music etc. Books or seminar on them Famous piece of art and music
Autobiography Bibliographies, Biographic works One's job or interest
Original Sounds Reference books, encyclopaedia, atlases Electronic Waves
An original religious event Different interpretations, Scholarly work Religious personalties
---------- ---------------- -----------

Primary Research

  • There are three types of primary research specifically commissioned for the problem at hand
      1. Qualitative
      1. Quantitative
      1. Experimental
Qualitative Research
  • It is about understanding decision-making
  • It is about one's feelings, urge or deep desires
  • It is about uncovering the key to either a problem or a solution
  • To access the hidden information,find out what drives one to do something
Quantitative Research
  • It is all about dealing with data, numbers and statistics
  • It is about measuring unmeasurable so it can be quantified and used in representation.
  • It is about scaling feelings / emotions on the scale of e.g., 1 ..2...3....10
Comparison
  • In quantitative survey questions are asked exactly the same way and in the same order while qualitative research uses a less structured discussion guide. A set of discussion topics with open-ended questions and probes that lead to the discussion. As a result, the moderator / experimenter can easily push respondents / participants to reflect and explore their feelings, perceptions, and behaviours.

Expectations:

+ A student and specially foreign student should adapt to an academic style thinking, leaving other preconceived notions aside, showing skills and talent in a way that is more acceptable in scientific socities.

Writing an Essay

To be able to write a technical piece of scientific research one should know the difference between different type of Essays. For example there is a difference between writing with emotions for the betterment of humanity and writing for the science and social sciences.

Difficulties faced by students
  • Grasping the question, the need to write and making logical and visible structure to guide them along in process of writing.
  • Dealing with Grammar and Punctuations and also sticking to rules.
  • Not making a habit of writing in same style.
Is writing an Essay a skill you learn or you are born with ?

Undoubtedly we all differs in what we can do, children born in a same family seems to be doing good in different areas. Similarly one of us may write better than others depending on educational backgrounds but having said that it is not like an abnormal difference in cognition or in special activity in neural pathways on the contrary it is an art / skill that can be learnt just like a sport. It requires your interest, your concentrated effort and your focused single mindedness. It goes like this, The more you use it the better it gets so it acts like a human muscle.

Students who do not seem to do well in this area may need to look at their innate behaviour. In order to make things work, sometimes machine needs tuning. This tuning of machine is to change one's habits which involves two main aspects:

  1. First is to be aware of your own action and reaction.
  2. Consciously swapping the usual response.

Once something is done consciously it remains in working and as well as in long term memory compare to things which are done unconsciously on auto-mode. If you are asked to answer this question How many times did you drink water yesterday? First you will be surprised to learn this question and shrug your shoulder and say who cares?

The key to the problem lies here ! Who cares!. We do not tend to care things which are already on auto-pilot. For example our pattern like breathing, walking, involuntarily movement of body parts, sleeping and so on. This list goes on and on and also differs from one person to another. As we all gather many things from our environment over the years advertently or inadvertently.

The normal person can not be bothered about drinking a glass of water and would reply to the question as who cares compare to the one who already know the importance of drinking enough water as a sport person. When a patient who is suffering from the kidney pain is made aware of the fact that the kidneys need more water. Once he is consciously accepted / registered this information, he would care about drinking water making sure that he/she drinks more than required minimum amount. Many times a person who usually drinks a can of coke after a meal would stop and swap it with a glass of water or some other beneficial liquid or a juice. This conscious change comes after being aware of the problems.

Thus for a student who is facing difficulty of writing an structured essay need to be aware of the shortcomings and

Referencing Tools

A software used for the purpose of incorporating references in an essay , research paper or in dissertation and in Phd thesis is often known as by the following name:

  1. Referencing software
  2. Refraining tools
  3. Reference Management Software
  4. Citation software and so on

Abstract

When reading scientific paper should be able to gather following things

  1. Importance
  2. Purpose
  3. Methods
    • Design
      • Qualitative
      • Quantitative
      • Combination
    • Sampling
    • Data Analysis
  4. key Findings

  5. Discussion / Conclusions

What does a Research Article consist of?

  • It is organized in a following way

    • Title
    • Keywords
    • Abstract
    • Introduction
    • Methods / Experimental
    • Results/Findings
      • Tables, Figures *
    • Discussion , limitaton, conclusion/Summary
    • Referecnes
  • First thing comes a Title. It can contain one or more of the following

    • Topic
    • Client Population
    • Methods
    • Interventions
    • Theory Tested

Examples:

  • Does Public Image of Nurses Matter?
    • This only contains a Topic
  • The Efficacy of a Brief Motivational Interventions for individuals with Eating Disorders: A Randomized Control Trial
    • This contains Topic, client population , Research Design

How to read an Journal Article / How to get most out of it

  • It is two face process
  • Do the quick Survey

    • Look for the figures, data, key words Title
    • Read the abstract
    • Read the conclusions
  • If the above makes sense then the second phase starts otherwise stop.

  • Read the Experimental
    • How work is done, what was done to better understand the meaning of the data and its interpretation
    • Take a note ! ( important)
What to be done when submitting your dissertation
  • How to submit the dissertation
    • Your dissertation is two parts one is the thesis of 90 % and 10 % Presentation. Both are essential and can not be missed at all. It is a 10 minutes dissertation.
  • Important Dates:
    • Ethics Jan 2020
    • Clear Ethics Feb 2020
    • Present Slides 5th Sep 2020
    • Presentation on 6th Sep 2020
    • Feedback 12th Sep 2019
    • Disseraton 27th September 2020 by 2pm
    • Feedback 15th November 2020

Your Writing should be:

  • based on apa style
  • clear, consice wording and accurate
  • Even choice of wording makes a difference
  • Straightforward objective and less reflective ( not your personal stories)
  • When doing literature review, you can not only say that

    • A did this
    • B did that and so on,
  • On the contrary you need to build an argument saying that

    • this is what they are doing
    • it is what I think, this is my opinion
    • these are strenght and weaknesses
  • Search High valued journel

    • You Need to know the journel credibility
    • Nature journel is the topmost one very high credibility
  • Define Key terms

    • EE refers to Expressed Emotions of .......
  • Use same words if they are used before

    • Children were the subject ....... Yongsters who did this.... { ambigious if youngsters is refering to Children then children must be used.}
  • Understand the use of Past , Present and Present Perfect tense.

    • Present: facts and truths generally accepted
    • Past: reporting an event Smith reported, event happend in particular time in past
    • Present Perfect: An event started in past and completed in present.
  • Do not use passive voice ( Avoid ) unless necessary

Thesis or Final Dissertation
  1. It takes more than two semister to be finished so you need to be clear from the day one what are you going to do because every project you do can help towards your dissertation.
  2. Your are automatically enrolled in a module called MOD002540 in your last tri semester
  3. Thesis is composed of two parts
  4. All submission ar online

    • Presentation is in both ppt and pdf
  5. How it is done.

    • W-1: Project list is emailed, read it and make a mind and make an appointment straight away to the supervisor.
    • W-2: Identify three top projects of interest.
      • Note: You can change your project in a week or so but you can not change your supervisor.
    • W-3:Fill in MSc project choice survey
    • W-5: Allocation announced
    • W-6 to 8: Prepare for the literature Review taking into consideration your literature Review
    • W-9: Monday ( 19/11/2019) dead line for literature Review
  6. Start working towards Ethics application ( Allow ample time for that and check ethical issues look for the dates for MSC dissertation)

  7. Check your e-vision to see your date
  8. Online MSc-project survey

Note : If you want to work on something which is not there, make a case ,

  • write two pages proposal stating

    • Research Question
    • Rational & hypothesis
    • Proposed Methodology
    • Executive plan Discuss:
    • Strength of proposal
    • Match with your supervisor expertise
    • your academic performance
  • W-6: Comments with your Supervision

  • W-7: Submit student led project from you to supervisor within 10 days of allocation.
  • W-8: Supervisor make a decision and project choice is settled
  • W-9: Monday deadline for submitting literature Review
  • W-10: Start working towards Ethics application

  • Note: Listen to your project supervisor

    • Contract must be signed with a supervisor
    • Meet your supervisor every two week
    • Use Gantt chart
    • Your dissertation is never complete- it has to be checked by your course leader- He/She gives you advise. Leave at least 15 days for this process alone, otherwise it will be rejected.

  • Be aware of keydates

  • Develop thesis statement
    • How do you do it
    • Select a topic of interest
    • Ask research question about that topic area that could be answered by examining the current literature
  • To come up with answers ask question in your area
  • Be inquisitive
  • Answerers will become thesis
  • Your paper or publication is the story of why your thesis is the answer to the questions
  • Keep it simple and direct
  • Make it clear from the beginning what you are saying

For example: Creativity and psychopathology

Ask question ? are artist or creative writer often depressed than less creative individuals ( if answer is yes) you opine as Artist and Writers are at great risk of mood change.

  • Sometimes on same topic critical evaluation can be contradictory. If this is the case why is it so?
    • Discuss different methodology
    • Any other reason
    • Certain type of research
    • Are sample comparable
    • Do the studies really address same hypothesis / question
    • What is power and power calculation ( % chances of findings)
    • When it comes to publish your paper
      • Think like a publisher
      • Understand politics of publishing work
  • you can re examine other people work
  • Do not editorialize: Avoid evaluative terms such as horrible, ridiculous or indefensible etc
  • Avoid negative words lke foolish ,completely ....
  • Avoid saying, it is obvious that it is correct
  • Do not use footnote
  • Do not use vague pronouns
do not say: This indicates
say: This result indicates
  • Do not include more than one point in a paragraph
  • Keep sentences short

26/10/2018

Qualitative Research

Qualitative Quantitative
Obsesrving ,Talking, Interviewing,Listening,Videoing Numbers
  • The techniques are known as soft skills and are improved like other skills, most jobs require a psychologist to have an Evaluation skills

  • All clinical / counselling work is done using Qualitative Research

  • There are three main techniques
  • Taken from bizfluent
    • Phenomenological Model Describing how any one participant experiences a specific event is the goal of the phenomenological method of research. This method utilizes interviews, observation and surveys to gather information from subjects. Phenomenology is highly concerned with how participants feel about things during an event or activity. Businesses use this method to develop processes to help sales representatives effectively close sales using styles that fit their personality.

    • Ethnographic Model The ethnographic model is one of the most popular and widely recognized methods of qualitative research; it immerses subjects in a culture that is unfamiliar to them. The goal is to learn and describe the culture's characteristics much the same way anthropologists observe the cultural challenges and motivations that drive a group. This method often immerses the researcher as a subject for extended periods of time. In a business model, ethnography is central to understanding customers. Testing products personally or in beta groups before releasing them to the public is an example of ethnographic research.

    • Grounded Theory Model The grounded theory method tries to explain why a course of action evolved the way it did. Grounded theory looks at large subject numbers. Theoretical models are developed based on existing data in existing modes of genetic, biological or psychological science. Businesses use grounded theory when conducting user or satisfaction surveys that target why consumers use company products or services. This data helps companies maintain customer satisfaction and loyalty.

    • Case Study Model Unlike grounded theory, the case study model provides an in-depth look at one test subject. The subject can be a person or family, business or organization, or a town or city. Data is collected from various sources and compiled using the details to create a bigger conclusion. Businesses often use case studies when marketing to new clients to show how their business solutions solve a problem for the subject.

    • Historical Model The historical method of qualitative research describes past events in order to understand present patterns and anticipate future choices. This model answers questions based on a hypothetical idea and then uses resources to test the idea for any potential deviations. Businesses can use historical data of previous ad campaigns and the targeted demographic and split-test it with new campaigns to determine the most effective campaign.

    • Narrative Model The narrative model occurs over extended periods of time and compiles information as it happens. Like a story narrative, it takes subjects at a starting point and reviews situations as obstacles or opportunities occur, although the final narrative doesn't always remain in chronological order. Businesses use the narrative method to define buyer persona to identify innovations that appeal to a target market.

Software use in Qualitative Data Analysis

  • There are loads of software used in this area a google search will give an idea about used software in market.
  • Udemy has a cours of using MAXQDA software which uses mixed model i.e., Qualitative and Quntitative and mixed mode

Methods in Researcdh

  • Ontology
  • Epistemology
  • Methodology

You need to understant these term and how they apply to research.

  • When these methods are clearly understood and critically evaluated it helps student to

    • Stay competent
    • Make better decission
    • Keep client safe
    • enable you to decide what should be applied to your practice
  • Ontology

    • It is a term used for beliefs about reality
    • Different kind of study is based upon different beliefs about what we think truth is.
      • Does Truth really exist?
    • What we think reality is, shapes/ has shaped / will shape what we think we can find out about reality.

Thus in order to discover something / find out about something we need to first start change our thinking pattern towards it.

In other words our perception of Truth influences what we think we can discover / find out / we can know

Similarly our pre conceived notion influences our thinking consequtively influences the discovery / findings or / knowing / knowledge

There are two types of Ontology and they are opposites

  • Realism and Relativism

    • Realists believe that only one truth exists. It is either dark or bright. In essence they believe black is only black and there are no shades of black or white.
    • Therefore Realist believe that Truth exist and it can not be changed. It is discovered using objective measurements.
    • If you belong to this group of realist and have this view about the reality then this view always influences the researcher every decision is made in the study.

    • Relativism, it is an opposite view of realism

      • Relativist believe in existence of multiple realities
      • What is real is shaped by the context or meaning you attached to it
      • Truth does not exist without meaning
      • Reality is created by how we see things, thus it evolves and changes depending on experience
      • And if it is context bound it can not be generalized instead it can only be transferred to other similar context
Realism Relativism
One Truth Exists Multiple version of truth exist
it does not change It changes and evolves
Objective measurement
Generalizable can be applied to other similar contxt

taken from statisticssolutions.com they offer help towards dissertation

The Literature Review, Part 1: What to Include

This blog is about what to include in your literature review. In short, the literature review is a snapshot of the current state of research on your topic, including research on study variables and major concepts or theories of your study. The literature review also helps to support your research problem and rationalize why your study is necessary by identifying gaps in the literature and the methodological weaknesses of previous studies. Below is what to include in your literature review.

Include recent, peer-reviewed studies and articles. These are really the meat of any literature review and what your literature review should primarily contain. Any historical or informational material on the topic should be included in background sections of your Introduction chapter or in a brief setup section at the beginning of the literature review.

Articles should ideally be recent within five years of the time you anticipate completing your dissertation. This five-year window, however, is not always required. Some schools allow articles to be recent within five to seven years, and some schools have no requirements. However, the intention of the literature review is to give readers a sense of the current state of research on your topic. So, in the spirit of writing an accurate and effective literature review, recent sources are recommended.

Additionally, most, if not all, material in your literature review should be peer reviewed. Peer reviewed means the article has been reviewed and deemed worthy of publication by several experts in the field. Usually, these experts are professors and researchers who are published and familiar with scholarship in the field, as well as the nature of scholarly publishing. To discover if an article is peer reviewed, consult Ulrichs guide to periodicals, which can be accessed through most university libraries.

Nikola Basics

Nikola : A modern static site generator with builtin jupyter notebook functionality


Nikol commands used.

    1.  > nikola version
    2.  > nikola init --quiet sayyedblogs
    3.  > nikola init --demo sayyedblogs
    4.  > nikola --help
    5.  > nikola build
    6.  > nikola serve  or nikola serve --browser or nikola serve -b or nikola auto
    7.  > nikola new_post
    8.  > nikola new_page
    9.  > nikola new_post -f markdown or -f ipynb
    10. > nikola help new_post
    11. > nikola new_post -F # To list all available format
    12. > nikola new_post -f markdown -t about # new page with about.md created with tile set to about
    13. > nikola theme -l # To get the list of install theme
    14. > nikola theme --list-installed  # to see the list of installed theme

Related Blogs

How nikola works

  • It is a python static site generator that used help from other existing site generators such as hugo and pelican. It has number of small pulgins that do the jobs. Here is the list of plug in that it uses.
  • For example notebook_shortcode is a plug in that allows embedding the notebook into the markdown files. But be careful, it may not work and distrub your settings.

Installing Nikola

  1. Create a Python virtual environment.
  2. Either create or choose your working directory, I created mkdir -p nikola in my project.
  3. Cd into nikola, activate your virtual environment
  4. Install nikola using pip with extras pip install nikola[extras]. On windows it takes time.
  5. Check the version nikola version. I have v8.1

Initialize nikola

  1. Run $ nikola init --quiet sayyedblogs. This will create a new directoy name sayyedblogs and create the following directories and one file. conf.py files/ galleries/ images/ listings/ pages/ posts/.
  2. All these directories are empty. The file conf.py comes with default installation options available.
  3. Get the help run nikola --help
Available commands:
  nikola auto                 builds and serves a site; automatically detects site changes, rebuilds, and optionally refreshes a browser
  nikola build                run tasks
  nikola check                check links and files in the generated site
  nikola clean                clean action / remove targets
  nikola console              start an interactive Python console with access to your site
  nikola default_config       Print the default Nikola configuration.
  nikola deploy               deploy the site
  nikola doit_auto            automatically execute tasks when a dependency changes
  nikola dumpdb               dump dependency DB
  nikola forget               clear successful run status from internal DB
  nikola github_deploy        deploy the site to GitHub Pages
  nikola help                 show help
  nikola ignore               ignore task (skip) on subsequent runs
  nikola import_wordpress     import a WordPress dump
  nikola info                 show info about a task
  nikola init                 create a Nikola site in the specified folder
  nikola list                 list tasks from dodo file
  nikola new_page             create a new page in the site
  nikola new_post             create a new blog post or site page
  nikola orphans              list all orphans
  nikola plugin               manage plugins
  nikola reset-dep            recompute and save the state of file dependencies without executing actions
  nikola rst2html             compile reStructuredText to HTML files
  nikola serve                start the test webserver
  nikola status               display site status
  nikola strace               use strace to list file_deps and targets
  nikola subtheme             given a swatch name from bootswatch.com or hackerthemes.com and a parent theme, creates a custom theme
  nikola tabcompletion        generate script for tab-completion
  nikola theme                manage themes
  nikola version              print the Nikola version number

  nikola help                 show help / reference
  nikola help <command>       show command usage
  nikola help <task-name>     show task usage

Build your site

  1. Run nikola build since we don't have any contents it will build an empty site.
  2. By default nikola build a site in output directory. Following files are created
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        11/07/2020     01:33                assets
d-----        11/07/2020     01:33                categories
d-----        11/07/2020     01:33                galleries
d-----        11/07/2020     01:33                images
d-----        11/07/2020     01:33                listings
-a----        11/07/2020     01:33           3451 archive.html
-a----        11/07/2020     01:33           3669 index.html
-a----        11/07/2020     01:33             93 robots.txt
-a----        11/07/2020     01:33            736 rss.xml
-a----        11/07/2020     01:33            916 sitemap.xml
-a----        11/07/2020     01:33            745 sitemapindex.xml

Start the server

  • Though we have not put any of our contents yet we can start the server nikola serve --browser. It starts the browser and serve it on local host port:80000. You can start the server on a different port nikola server -p 2320
  • When site is built all configuration files are read from conf.py, we will refer this file as config file hereafter.
  • By default it uses the many options already set to default values.
  • Nikola creates a directory named ouput where all files and folders are created that is served to the website.
  • The landing page is created at the root of the output directroy as index.html. This page is created automatically.
  • It has three sections:
  • Html meta-data
  • Page nave-bar taken from the theme used
  • Page contents ( not defined yet)
  • Bottom script.
  • Since everything is generated automatically, we are not goingto touch it yet we have to.
  • By default Nikola uses bootblog4 theme, we are going to use a different one.

Note: Commit time.

sayyed@neuro ~/n/p/n/mysite (dev)> gitcommit -m "@dev:Structure is working."                              (nikola) 
[dev 8c4958e] dev:Structure is working.
 7 files changed, 335 insertions(+), 32 deletions(-)
 create mode 100644 pages/about.rst
 create mode 100644 pages/index.rst
 create mode 100644 posts/001_intro.ipynb
 create mode 100644 posts/002_basics.ipynb
sayyed@neuro ~/n/p/n/mysite (dev)>